Repository navigation
Multiple delivery addresses on one cart / order #2739
wychoong
started this conversation in
Feedback & Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Feature request: ship different lines on one cart/order to different delivery addresses.
v2 added multiple fulfilments (split parcels, locations, methods). That still does not unlock multiple destinations. Fulfilments split what goes out and from where; the to where is still one shipping address on the cart/order.
Current Lunar shape
A cart has one shipping address and one billing address.
Cart::shippingAddress()is aHasOnefiltered bytype = shipping. Setting a shipping address deletes any existing one of that type:The chosen shipping option is a single identifier on that address (
SetShippingOptionwritesshippingAddress.shipping_option).ShippingManifest::getOptions($cart)/getShippingOption($cart)resolve options for the whole cart against that one address.Cart totals follow the same assumption:
ApplyShippingputs one option intoshippingBreakdown$cart->shippingAddressfor every line (CalculateTax)collect) whenCart::isShippable()The order copies that 1:1.
Order::shippingAddress()is alsoHasOne.CreateOrderAddressesmatches cart addresses to order addresses by type, so even extratype = shippingrows would collapse onto one order shipping address (last write wins).A
Fulfilmenthaslocation_id— the warehouse it ships from — plus lines/qty, method, tracking. There is no destination address on the fulfilment. Split/merge reorganise outstanding quantities for the same order; they do not attach a second delivery address.Cart.merged_idis guest → user cart merge (MergeCart), not a parent/child split for multi-address checkout.So: one cart → one shipping address → one shipping option/charge → one order shipping address → N fulfilments that all deliver to that address.
The challenge
Multiple shipping addresses means multiple shipping options and charges (different zones, rates, possibly tax). Lunar's cart is a single shipping context. You cannot today:
v2 fulfilments already cover "two parcels, same destination" (in-stock now / rest later, shipping + digital). They do not cover "two parcels, two destinations."
Workaround we have been using
Parent cart → child carts:
Problems with that workaround
Checked against current core — these are real, not hypothetical.
Double sales / inventory.
createOrder()is per cart. If the parent and the children all become orders, lines and stock movements are counted twice. If only the children become orders, the payment/transactions live on a cart that has no order (or a parent order with no lines). If only the parent becomes an order, the per-address shipping quotes on the children never become shipping lines on that order (CreateShippingLinereads the parent's single option). Lunar has no first-class "this cart is a payment shell / these carts are fulfilment shells" relationship.merged_iddoes the opposite (fold source into target and retire the source).Many child orders vs one parent order with fulfilments. Operationally you either:
Neither is wrong as an ops model, but core does not pick one. Subjective, and both fight the current 1:1 cart → order → shipping address shape.
Tax and discounts stay cart-global. All lines are taxed from one shipping address; coupon/discount is on the cart, not per destination. Splitting into child carts also splits (or duplicates) discount application.
What would unlock it
A first-class path would need, at least:
ShippingBreakdownItems;ApplyShippingonly ever inserts one)location_idUntil then, multiple delivery addresses stay a storefront workaround with the inventory/sales pitfalls above.
All reactions