core/app/models/spree/calculator/per_item.rb
# 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.
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.
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
       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
def matching_products if self . calculable . respond_to? ( :promotion ) self . calculable . promotion . rules . map do | rule | rule . respond_to? ( :products ) ? rule . products : [ ] end . flatten end end
Returns all products that match this calculator, but only if the calculator
is attached to a promotion.
Returns all products that match this calculator but only if the calculator is attached to a promotion .
# 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