Class: Spree::Orders::BuildShipments
- Inherits:
-
Object
- Object
- Spree::Orders::BuildShipments
- Includes:
- ServiceModule::Base
- Defined in:
- app/services/spree/orders/build_shipments.rb
Overview
Shared shipment-building step for admin order Create / Update.
Rebuilds shipments from scratch (Stock::Coordinator), then layers in tax, costs, and free-shipping promotions so totals reflect delivery before payment is requested. Without this, draft orders would expose delivery_total: 0.0 until completion is attempted — which is too late.
No-op when the order has no shipping address, no line items, or does not require delivery (digital orders, etc.).
Instance Method Summary collapse
Methods included from ServiceModule::Base
Instance Method Details
#call(order:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/spree/orders/build_shipments.rb', line 15 def call(order:) return success(order) unless order.ship_address_id.present? return success(order) unless order.line_items.any? return success(order) unless order.delivery_required? order.create_proposed_shipments order.create_shipment_tax_charge! order.set_shipments_cost order.apply_free_shipping_promotions success(order) end |