Sha256: 88ae476897ff75db7bfa83dc64d17896f914e83f75e9b5452b6d5e7b3769ee1a

Contents?: true

Size: 598 Bytes

Versions: 4

Compression:

Stored size: 598 Bytes

Contents

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.update!
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_subscriptions-alpha-0.0.5 app/models/solidus_subscriptions/subscription_line_item_builder.rb
solidus_subscriptions-alpha-0.0.3 app/models/solidus_subscriptions/subscription_line_item_builder.rb
solidus_subscriptions-alpha-0.0.2 app/models/solidus_subscriptions/subscription_line_item_builder.rb
solidus_subscriptions-alpha-0.0.1 app/models/solidus_subscriptions/subscription_line_item_builder.rb