Class: Spree::Promotion::Actions::CreateItemAdjustments
Instance Method Summary
collapse
#free_shipping?, #human_description, #human_name, #key
Instance Method Details
#compute_amount(line_item) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/models/spree/promotion/actions/create_item_adjustments.rb', line 19
def compute_amount(line_item)
return 0 unless promotion.line_item_actionable?(line_item.order, line_item)
amounts = [line_item.amount, compute(line_item)]
order = line_item.order
amounts << order.amount - order.adjustments.eligible.sum(:amount).abs if order.adjustments.eligible.any?
amounts.min * -1
end
|
10
11
12
13
14
15
16
17
|
# File 'app/models/spree/promotion/actions/create_item_adjustments.rb', line 10
def perform(options = {})
order = options[:order]
promotion = options[:promotion]
create_unique_adjustments(order, order.line_items) do |line_item|
promotion.line_item_actionable?(order, line_item)
end
end
|