Sha256: a263dadd9e54da9fb86e8afe677face9d823e5d01b8a91aa295bd1f18188b69d

Contents?: true

Size: 641 Bytes

Versions: 7

Compression:

Stored size: 641 Bytes

Contents

# frozen_string_literal: true

module SolidusSubscriptions
  module SubscriptionLineItemBuilder
    private

    def create_subscription_line_item(line_item)
      SolidusSubscriptions::LineItem.create!(
        subscription_params.merge(spree_line_item: line_item)
      )

      # Rerun the promotion handler to pickup subscription promotions
      ::Spree::PromotionHandler::Cart.new(line_item.order).activate
      line_item.order.recalculate
    end

    def subscription_params
      params.require(:subscription_line_item).permit(
        SolidusSubscriptions.configuration.subscription_line_item_attributes
      )
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solidus_subscriptions-2.0.2 lib/solidus_subscriptions/subscription_line_item_builder.rb
solidus_subscriptions-2.0.1 lib/solidus_subscriptions/subscription_line_item_builder.rb
solidus_subscriptions-2.0.0 lib/solidus_subscriptions/subscription_line_item_builder.rb
solidus_subscriptions-1.1.0 lib/solidus_subscriptions/subscription_line_item_builder.rb
solidus_subscriptions-1.0.1 lib/solidus_subscriptions/subscription_line_item_builder.rb
solidus_subscriptions-1.0.0 lib/solidus_subscriptions/subscription_line_item_builder.rb
solidus_subscriptions-1.0.0.rc1 lib/solidus_subscriptions/subscription_line_item_builder.rb