Sha256: 2525fee5d51320006818ba4a8945e23572ff49d88029484f6a46a6e03506b610
Contents?: true
Size: 825 Bytes
Versions: 2
Compression:
Stored size: 825 Bytes
Contents
module Spree class Promotion module Actions class CreateLineItems < PromotionAction has_many :promotion_action_line_items, :foreign_key => :promotion_action_id accepts_nested_attributes_for :promotion_action_line_items attr_accessible :promotion_action_line_items_attributes delegate :eligible?, :to => :promotion def perform(options = {}) return unless order = options[:order] return unless eligible?(order) promotion_action_line_items.each do |item| current_quantity = order.quantity_of(item.variant) if current_quantity < item.quantity order.add_variant(item.variant, item.quantity - current_quantity) order.update! end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_promo-1.3.5 | app/models/spree/promotion/actions/create_line_items.rb |
spree_promo-1.3.4 | app/models/spree/promotion/actions/create_line_items.rb |