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

Inherits:
ShippingCalculator show all
Defined in:
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, register, #to_s

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

- (Object) compute_from_quantity(quantity)



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

def compute_from_quantity(quantity)
  preferred_amount * quantity
end

- (Object) compute_package(package)



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

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