From 9c3eb3725ea50388eb368deef163e30c4314b7db Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Mon, 15 Jun 2020 21:12:45 +0100 Subject: [PATCH] Remove dead code related to promotions, we dont have promotions in OFN --- app/models/spree/calculator/per_item.rb | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/app/models/spree/calculator/per_item.rb b/app/models/spree/calculator/per_item.rb index 10c7965c0d..fdd9aa4a5b 100644 --- a/app/models/spree/calculator/per_item.rb +++ b/app/models/spree/calculator/per_item.rb @@ -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