Class: Spree::Calculator::PercentPerItem
- Inherits:
-
Spree::Calculator
- Object
- ActiveRecord::Base
- Base
- Spree::Calculator
- Spree::Calculator::PercentPerItem
- Defined in:
- app/models/spree/calculator/percent_per_item.rb
Overview
A calculator for promotions that calculates a percent-off discount for all matching products in an order. This should not be used as a shipping calculator since it would be the same thing as a flat percent off the entire order.
TODO Should be deprecated now that we have adjustments at the line item level in spree core
Instance Method Summary collapse
Methods inherited from Spree::Calculator
#available?, calculators, description, #description, #to_s
Methods inherited from Base
display_includes, page, preference, #preferences
Methods included from Spree::Core::Permalinks
#generate_permalink, #save_permalink
Instance Method Details
#compute(object = nil) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/models/spree/calculator/percent_per_item.rb', line 17 def compute(object = nil) Spree::Deprecation.warn('This method is deprecated, please use adjustments at line item level') return 0 if object.nil? object.line_items.sum { |line_item| value_for_line_item(line_item) } end |