Class: Spree::Calculator::Shipping::FlatPercentItemTotal
Class Method Summary
collapse
Instance Method Summary
collapse
#available?, #compute_shipment
#available?, calculators, #compute, #description, #to_s
Class Method Details
.description ⇒ Object
8
9
10
|
# File 'app/models/spree/calculator/shipping/flat_percent_item_total.rb', line 8
def self.description
Spree.t(:flat_percent)
end
|
Instance Method Details
#compute_from_price(price) ⇒ Object
16
17
18
19
|
# File 'app/models/spree/calculator/shipping/flat_percent_item_total.rb', line 16
def compute_from_price(price)
value = price * BigDecimal(preferred_flat_percent.to_s) / 100.0
(value * 100).round.to_f / 100
end
|
#compute_package(package) ⇒ Object
12
13
14
|
# File 'app/models/spree/calculator/shipping/flat_percent_item_total.rb', line 12
def compute_package(package)
compute_from_price(total(package.contents))
end
|