Class: Spree::Calculator::Shipping::FlexiRate
Instance Method Summary
collapse
#available?
#available?, #compute, description, #description, #to_s
Instance Method Details
#compute_from_quantity(quantity) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/models/spree/calculator/shipping/flexi_rate.rb', line 18
def compute_from_quantity(quantity)
sum = 0
max = preferred_max_items.to_i
quantity.times do |index|
sum += if (max == 0 && index == 0) || (max > 0) && (index % max == 0)
preferred_first_item.to_f
else
preferred_additional_item.to_f
end
end
sum
end
|
#compute_package(package) ⇒ Object
14
15
16
|
# File 'app/models/spree/calculator/shipping/flexi_rate.rb', line 14
def compute_package(package)
compute_from_quantity(package.contents.sum(&:quantity))
end
|