Class: Spree::Calculator::Shipping::PerItem

Inherits:
ShippingCalculator show all
Defined in:
core/app/models/spree/calculator/shipping/per_item.rb

Instance Method Summary collapse

Methods inherited from ShippingCalculator

#available?, #compute_shipment

Methods inherited from Spree::Calculator

#available?, calculators, #compute, description, #description, #to_s

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Instance Method Details

#compute_from_quantity(quantity) ⇒ Object



16
17
18
# File 'core/app/models/spree/calculator/shipping/per_item.rb', line 16

def compute_from_quantity(quantity)
  preferred_amount * quantity
end

#compute_package(package) ⇒ Object



12
13
14
# File 'core/app/models/spree/calculator/shipping/per_item.rb', line 12

def compute_package(package)
  compute_from_quantity(package.contents.sum(&:quantity))
end