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

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ShippingCalculator

#available?, #compute_shipment

Methods inherited from Spree::Calculator

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

Class Method Details

.descriptionObject



9
10
11
# File 'app/models/spree/calculator/shipping/per_item.rb', line 9

def self.description
  Spree.t(:shipping_flat_rate_per_item)
end

Instance Method Details

#compute_package(package) ⇒ Object



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

def compute_package(package)
  content_items = package.contents
  self.preferred_amount * content_items.sum { |item| item.quantity }
end