mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove dead code related to promotions, we dont have promotions in OFN
This commit is contained in:
@@ -21,32 +21,11 @@ module Spree
|
||||
return 0 if object.nil?
|
||||
|
||||
number_of_line_items = line_items_for(object).reduce(0) do |sum, line_item|
|
||||
value_to_add = if matching_products.blank? || matching_products.include?(line_item.product)
|
||||
line_item.quantity
|
||||
else
|
||||
0
|
||||
end
|
||||
value_to_add = line_item.quantity
|
||||
sum + value_to_add
|
||||
end
|
||||
preferred_amount * number_of_line_items
|
||||
end
|
||||
|
||||
# Returns all products that match this calculator, but only if the calculator
|
||||
# is attached to a promotion. If attached to a ShippingMethod, nil is returned.
|
||||
def matching_products
|
||||
# Regression check for #1596
|
||||
# Calculator::PerItem can be used in two cases.
|
||||
# The first is in a typical promotion, providing a discount per item of a particular item
|
||||
# The second is a ShippingMethod, where it applies to an entire order
|
||||
#
|
||||
# Shipping methods do not have promotions attached, but promotions do
|
||||
# Therefore we must check for promotions
|
||||
if self.calculable.respond_to?(:promotion)
|
||||
self.calculable.promotion.rules.map do |rule|
|
||||
rule.respond_to?(:products) ? rule.products : []
|
||||
end.flatten
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user