DeliveryGroup - Liquid Object Reference
On this page
Description
The DeliveryGroup object is one of the deliveries a cart splits into when multi-shipping is enabled. Items are grouped by the shipping methods their products offer, counting only the methods the store can quote on the web, and the customer chooses a method for each delivery. See how items are grouped for which methods count.
Reach them through current_cart.delivery_groups. A cart that is not split still returns one group, so you do not need separate markup for a single delivery.
```liquid
{% for group in current_cart.delivery_groups %}
{% endfor %} ```
Attributes
| Attribute | Type | Description |
|---|---|---|
cheapest_rate |
ShippingRate | Returns the cheapest rate for this delivery that is not a pickup, or nil |
items |
List[CartItem] | Returns the cart items in this delivery |
key |
String | Returns the identifier for this delivery, used to name the delivery’s form field when the form is submitted |
pickup_options |
List[PickupOption] | Returns the pickup options available to this delivery, with stock checked against this delivery’s items only |
rates |
List[ShippingRate] | Returns the shipping rates available to this delivery |
shipping_methods |
List[String] | Returns the shipping methods available to this delivery |
Available on
- Cart - Liquid Object Reference —
delivery_groups, andmultiple_delivery_groups?to branch before fetching rates
Rendering the groups is what saves them
Rendering current_cart.delivery_groups also persists the quoted deliveries onto the cart, and the checkout validation step requires them to be there. Always present the choices through this collection, or through item.delivery_group, which persists the same way. If you build the markup from anything else, checkout has nothing to validate against and rejects the submission.
multiple_delivery_groups? groups the items without fetching any rates. Use it to decide what to render before running a rate lookup.
Submitting a choice
Post one selection per delivery, in a radio named method[<group_key>]. The radio value is a rate’s form_value, or Click and Collect_<stock location id>_<collection point id> for a pickup.
A submission missing a delivery is rejected, as is one quoted against a cart whose items, quantities, methods or address have since changed. The customer is returned to the shipping step to choose again.
Loading the selector without blocking the page
Rate lookups can be slow, so the built-in shipping step renders its selector through a deferred component:
```liquid
{% component “checkout/shipping_rates/page”, defer: true %} ```
defer: true renders a placeholder and loads the component as soon as the component loader on the page registers it. This is not the same as lazy: true, which renders an empty container that loads only when one of the reload: events set on it fires.
Assigning deliveries from a theme
A theme can assign deliveries itself rather than asking the customer, using the shipping.add action to nominate the items each shipment covers. Those groups are marked as theme-assigned and survive a rate refresh instead of being regrouped, for as long as the cart still matches what they were saved against. The assignment is discarded when the items, quantities or address change, or when anything else would regroup the items, such as a change to a product’s Shipping Methods or to the store’s shipping providers and rates. Automatic grouping then resumes until the theme calls shipping.add again.
Items left in no delivery produce no shipment at all. When you assign deliveries, StoreConnect reports those items as a warning in the web console. See Action - Liquid Tag Reference.
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.