Class: Spree::Cart::EstimateShippingRates
- Inherits:
-
Object
- Object
- Spree::Cart::EstimateShippingRates
- Includes:
- ServiceModule::Base
- Defined in:
- app/services/spree/cart/estimate_shipping_rates.rb
Instance Method Summary collapse
Methods included from ServiceModule::Base
Instance Method Details
#call(order:, country_iso: nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/services/spree/cart/estimate_shipping_rates.rb', line 6 def call(order:, country_iso: nil) country_id = country_id(country_iso) dummy_order = generate_dummy_order(order, country_id) packages = ::Spree::Stock::Coordinator.new(dummy_order).packages estimator = ::Spree::Stock::Estimator.new(dummy_order) shipping_rates = if order.line_items.any? && packages.any? estimator.shipping_rates(packages.first) else [] end success(shipping_rates) end |