Class: Spree::Adjustable::Adjuster::Promotion

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree/adjustable/adjuster/promotion.rb

Instance Method Summary collapse

Methods inherited from Base

adjust, #initialize

Constructor Details

This class inherits a constructor from Spree::Adjustable::Adjuster::Base

Instance Method Details

#updateObject


5
6
7
8
9
10
11
12
# File 'app/models/spree/adjustable/adjuster/promotion.rb', line 5

def update
  promo_adjustments = adjustments.competing_promos.reload.map { |a| a.update!(adjustable) }
  promos_total = promo_adjustments.compact.sum
  choose_best_promo_adjustment unless promos_total == 0
  promo_total = best_promo_adjustment.try(:amount).to_f if best_promo_adjustment.try(:promotion?)

  update_totals(promo_total)
end