Class: Spree::Stock::Estimator
- Inherits:
-
Object
- Object
- Spree::Stock::Estimator
- Defined in:
- app/models/spree/stock/estimator.rb
Defined Under Namespace
Classes: OrderRequired, ShipmentRequired
Instance Method Summary collapse
-
#shipping_rates(package, frontend_only = true) ⇒ Array<Spree::ShippingRate>
Estimate the shipping rates for a package.
Instance Method Details
#shipping_rates(package, frontend_only = true) ⇒ Array<Spree::ShippingRate>
Estimate the shipping rates for a package.
16 17 18 19 20 21 22 23 24 |
# File 'app/models/spree/stock/estimator.rb', line 16 def shipping_rates(package, frontend_only = true) raise ShipmentRequired if package.shipment.nil? raise OrderRequired if package.shipment.order.nil? rates = calculate_shipping_rates(package) rates.select! { |rate| rate.shipping_method.available_to_users? } if frontend_only choose_default_shipping_rate(rates) Spree::Config.shipping_rate_sorter_class.new(rates).sort end |