Sha256: cae31db4d0f9ba781512b908bc25e6706961a1bf0e3b66999fc3b59f7a734f63

Contents?: true

Size: 672 Bytes

Versions: 9

Compression:

Stored size: 672 Bytes

Contents

Spree::OrderUpdater.class_eval do
  unless self.method_defined?('update_adjustments_with_promotion_limiting')
    def update_adjustments_with_promotion_limiting
      update_adjustments_without_promotion_limiting
      return if adjustments.promotion.eligible.none?
      most_valuable_adjustment = adjustments.promotion.eligible.max{|a,b| a.amount.abs <=> b.amount.abs}
      current_adjustments = (adjustments.promotion.eligible - [most_valuable_adjustment])
      current_adjustments.each do |adjustment|
        adjustment.update_attribute_without_callbacks(:eligible, false)
      end
    end
    alias_method_chain :update_adjustments, :promotion_limiting
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
spree_promo-1.3.5 app/models/spree/order_updater_decorator.rb
spree_promo-1.3.4 app/models/spree/order_updater_decorator.rb
spree_promo-1.3.3 app/models/spree/order_updater_decorator.rb
spree_promo-1.3.2 app/models/spree/order_updater_decorator.rb
spree_promo-1.3.1 app/models/spree/order_updater_decorator.rb
spree_promo-1.3.0 app/models/spree/order_updater_decorator.rb
spree_promo-1.3.0.rc2 app/models/spree/order_updater_decorator.rb
dup_spree_promo-1.3.0.rc1 app/models/spree/order_updater_decorator.rb
spree_promo-1.3.0.rc1 app/models/spree/order_updater_decorator.rb