---
title: Support shipping and pickup delivery groups in a cart
description: >-
  Learn how a cart's delivery groups can include a pickup group, and how to read
  every group and select delivery options with the Storefront API.
source_url:
  html: >-
    https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/cart/delivery-groups
  md: >-
    https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/cart/delivery-groups.md
api_name: storefront
---

# Support shipping and pickup delivery groups in a cart

A cart's [delivery groups](https://shopify.dev/docs/api/storefront/latest/objects/Cart#field-Cart.fields.deliveryGroups) organize its lines by how they're delivered. Each group has its own delivery options, its own selected option, and its own estimated cost. A cart can have any combination of shipping and pickup groups: only shipping groups, only pickup groups, or both at the same time.

This guide is for developers who show a cart's delivery options in a custom storefront or app.

**Behavior change for existing integrations:**

Shopify is rolling out pickup groups in `Cart.deliveryGroups` store by store, and the change affects every version of the Storefront API. If your storefront reads only the first delivery group, or assumes that every group is a shipping group, then [update your integration](#update-an-existing-integration).

***

## What you'll learn

In this guide, you'll learn how to do the following tasks:

* Query every delivery group in a cart.
* Tell shipping groups and pickup groups apart.
* Show each group's delivery method and its items.
* Select a delivery option for each group.
* Read the cart again after the buyer returns from checkout.
* Update an existing integration that assumes one shipping group.

***

## How it works

If your storefront or app reads `deliveryGroups`, then handle every group that it returns, and don't assume that a cart has only one shipping group. An integration that reads only the cart's lines doesn't need to handle delivery groups. A cart's lines are split into delivery groups as follows:

* Subscription lines get delivery groups of their own, with a `groupType` of `SUBSCRIPTION`.
* One-time purchase lines are in groups with a `groupType` of `ONE_TIME_PURCHASE`, which can also hold a subscription's first delivery. Items that ship are in shipping groups, and items that the buyer picks up are in a pickup group, depending on what the buyer chose in checkout.
* A line that doesn't need shipping, such as a digital item, can be in no delivery group.

When a buyer chooses delivery options in checkout, checkout updates the cart's delivery groups. The following table shows examples of the delivery groups that a cart's one-time purchase lines can have:

| Buyer's choice in checkout | Delivery groups for one-time purchase lines |
| - | - |
| Ship every item. | One shipping group. |
| Pick up every item. | One pickup group. |
| Ship some items and pick up the others. | One shipping group and one pickup group. |

Checkout splits a cart between shipping and pickup only in stores that use ship and pickup in one order. In other stores, the buyer ships every item or picks up every item. The table doesn't show every case. For the other cases, refer to [Limitations](#limitations).

Delivery groups don't have a fixed order, so a pickup group can come before a shipping group. A group's `id` can change whenever checkout or a cart mutation changes the cart's groups, so always use the IDs from your most recent response.

***

## Requirements

* You've completed the [Getting started with the Storefront API](https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/getting-started) guide.

- You've [enabled local pickup](https://help.shopify.com/en/manual/shipping/setting-up-and-managing-your-shipping/local-methods/local-pickup) for one or more of your store's locations.
- To test carts that ship some items and pick up others, you have a store that uses ship and pickup in one order: a Shopify Plus store, or a dev store that you [create](https://shopify.dev/docs/apps/build/stores/development-stores#create-a-dev-store) with the **Market-driven shipping and ship & pickup in one order** feature preview.

***

## Step 1: Query every delivery group

Query `Cart.deliveryGroups` with a `first` that's large enough to return every group, and request `pageInfo` so that you can tell whether any groups were left out. The following example requests up to 10 groups. Set `cartId` to the full cart ID that `cartCreate` returned, with its `key` parameter. Without the key, the response can have the cart's lines but no delivery groups.

For each group, request its lines, its delivery address, its delivery options, and its selected option. Include the `deliveryMethodType` of the selected option, because you use it in the next step. The example puts these fields in a fragment, so that the mutation in [Step 4](#step-4-select-a-delivery-option-for-each-group) can request the same fields.

By default, a query doesn't calculate a shipping group's carrier-calculated rates. To request them, refer to [Fetching carrier-calculated rates for the cart using defer](https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/defer#fetching-carrier-calculated-rates-for-the-cart-using-defer).

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL query

```graphql
query CartDeliveryGroups($cartId: ID!) {
  cart(id: $cartId) {
    deliveryGroups(first: 10) {
      nodes {
        ...CartDeliveryGroupFields
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }
}


fragment CartDeliveryGroupFields on CartDeliveryGroup {
  id
  groupType
  cartLines(first: 250) {
    nodes {
      id
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
  deliveryAddress {
    id
    address1
    city
    provinceCode
    countryCodeV2
    zip
  }
  deliveryOptions {
    handle
    title
    deliveryMethodType
    estimatedCost {
      amount
      currencyCode
    }
  }
  selectedDeliveryOption {
    handle
    title
    deliveryMethodType
    estimatedCost {
      amount
      currencyCode
    }
  }
}
```

## JSON response

```json
{
  "data": {
    "cart": {
      "deliveryGroups": {
        "nodes": [
          {
            "id": "gid://shopify/CartDeliveryGroup/0b7e2a9f4c1d8e36a5f0c2b9d4e7a1c3?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw",
            "groupType": "ONE_TIME_PURCHASE",
            "cartLines": {
              "nodes": [
                {
                  "id": "gid://shopify/CartLine/2f9c3b1e-7a4d-4e8b-9c6f-1d2e3f4a5b6c?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw"
                }
              ],
              "pageInfo": {
                "hasNextPage": false,
                "endCursor": "eyJsYXN0X2lkIjoxLCJsYXN0X3ZhbHVlIjoiMmY5YzNiMWUtN2E0ZC00ZThiLTljNmYtMWQyZTNmNGE1YjZjIn0="
              }
            },
            "deliveryAddress": {
              "id": "gid://shopify/MailingAddress/3?model_name=Location",
              "address1": null,
              "city": null,
              "provinceCode": null,
              "countryCodeV2": null,
              "zip": null
            },
            "deliveryOptions": [
              {
                "handle": "4c8f1e2a9b7d3c6e5f0a1b2c3d4e5f60",
                "title": "Downtown store",
                "deliveryMethodType": "PICK_UP",
                "estimatedCost": {
                  "amount": "0.0",
                  "currencyCode": "CAD"
                }
              },
              {
                "handle": "9a1b2c3d4e5f60718293a4b5c6d7e8f9",
                "title": "Kanata store",
                "deliveryMethodType": "PICK_UP",
                "estimatedCost": {
                  "amount": "0.0",
                  "currencyCode": "CAD"
                }
              }
            ],
            "selectedDeliveryOption": {
              "handle": "4c8f1e2a9b7d3c6e5f0a1b2c3d4e5f60",
              "title": "Downtown store",
              "deliveryMethodType": "PICK_UP",
              "estimatedCost": {
                "amount": "0.0",
                "currencyCode": "CAD"
              }
            }
          },
          {
            "id": "gid://shopify/CartDeliveryGroup/d41d8cd98f00b204e9800998ecf8427e?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw",
            "groupType": "ONE_TIME_PURCHASE",
            "cartLines": {
              "nodes": [
                {
                  "id": "gid://shopify/CartLine/8e7d6c5b-4a39-4281-b7c6-d5e4f3a2b1c0?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw"
                }
              ],
              "pageInfo": {
                "hasNextPage": false,
                "endCursor": "eyJsYXN0X2lkIjoxLCJsYXN0X3ZhbHVlIjoiOGU3ZDZjNWItNGEzOS00MjgxLWI3YzYtZDVlNGYzYTJiMWMwIn0="
              }
            },
            "deliveryAddress": {
              "id": "gid://shopify/MailingAddress/0?model_name=Address",
              "address1": "150 Elgin St",
              "city": "Ottawa",
              "provinceCode": "ON",
              "countryCodeV2": "CA",
              "zip": "K2P 1L4"
            },
            "deliveryOptions": [
              {
                "handle": "b709d6e6b08ffb9d93d8bc0a23d76d44",
                "title": "Standard",
                "deliveryMethodType": "SHIPPING",
                "estimatedCost": {
                  "amount": "8.0",
                  "currencyCode": "CAD"
                }
              },
              {
                "handle": "e3b0c44298fc1c149afbf4c8996fb924",
                "title": "Express",
                "deliveryMethodType": "SHIPPING",
                "estimatedCost": {
                  "amount": "18.0",
                  "currencyCode": "CAD"
                }
              }
            ],
            "selectedDeliveryOption": {
              "handle": "b709d6e6b08ffb9d93d8bc0a23d76d44",
              "title": "Standard",
              "deliveryMethodType": "SHIPPING",
              "estimatedCost": {
                "amount": "8.0",
                "currencyCode": "CAD"
              }
            }
          }
        ],
        "pageInfo": {
          "hasNextPage": false,
          "endCursor": "eyJsYXN0X2lkIjoyLCJsYXN0X3ZhbHVlIjoiMCJ9"
        }
      }
    }
  }
}
```

If `pageInfo.hasNextPage` is `true` for the groups or for a group's `cartLines`, then request the next page, as [Paginating results with GraphQL](https://shopify.dev/docs/api/usage/pagination-graphql) describes.

***

## Step 2: Identify each group's delivery method

To find out how a group is delivered, read the `deliveryMethodType` of its `selectedDeliveryOption`.

* `SHIPPING`: The group's items ship to its `deliveryAddress`.
* `PICK_UP`: The buyer picks up the group's items at a store. The selected option is the group's store.
* Other values, such as `LOCAL` and `PICKUP_POINT`: Handle these values depending on what your storefront supports.

Don't infer a group's delivery method from its position in the list, from the number of groups, or from its `deliveryAddress`. A pickup group can keep a shipping address, but its items aren't shipped there. The [`CartDeliveryGroup`](https://shopify.dev/docs/api/storefront/latest/objects/CartDeliveryGroup) reference describes each field.

**Note:**

In API version 2027-01 and later, [`Cart.delivery.methods`](https://shopify.dev/docs/api/storefront/2027-01/objects/CartDelivery) lists the cart's delivery methods, such as shipping and pickup. Each method's `deliveryMethodType` is `SHIPPING` or `PICK_UP` and is never `null`, and its `groups` field returns the delivery groups that use the method. So you can tell shipping from pickup for a group that a method returns, even when its `selectedDeliveryOption` is `null`. When a group has a `selectedDeliveryOption`, still read its `deliveryMethodType`, because a shipping method also returns local delivery groups, and a method's `groups` field doesn't return every group.

***

## Step 3: Show each group to the buyer

Show each group's lines with the group's delivery method:

* For a shipping group, show `deliveryAddress` as the address that the items ship to.
* For a pickup group, show the `title` of `selectedDeliveryOption`, which usually names the store that the buyer picks up from. Don't show the group's `deliveryAddress` as a shipping address.

Step 1 requests only the `id` of each line. To show a line's item, find the line with the same `id` in every page of the cart's [`lines`](https://shopify.dev/docs/api/storefront/latest/objects/Cart#field-Cart.fields.lines) field. A group has a bundle's component lines, not the bundle's line, so for a bundle, look in the `lineComponents` of the bundle's line. While the cart calculates delivery options, a group can keep older line IDs, so show a line that you can't find without its item details.

**Note:**

In API version 2027-01 and later, you can read the pickup store from the `CartPickUpMethod` in `Cart.delivery.methods`. The method's selected destination has the store's [`Location`](https://shopify.dev/docs/api/storefront/2027-01/objects/Location), with its name and address. You can read it even when the pickup group's `selectedDeliveryOption` is `null`. On a cart that hides the buyer's destination from your storefront, the method lists no destinations, but the cart keeps the pickup store. For such a cart, show the `title` of `selectedDeliveryOption` instead. To read the `Location`, your storefront needs the [`unauthenticated_read_product_pickup_locations`](https://shopify.dev/docs/api/usage/access-scopes#unauthenticated_read_product_pickup_locations) access scope. Without it, the request returns an access denied error and no cart.

***

## Step 4: Select a delivery option for each group

Use the [`cartSelectedDeliveryOptionsUpdate`](https://shopify.dev/docs/api/storefront/latest/mutations/cartSelectedDeliveryOptionsUpdate) mutation to select a delivery option. Build each request from every group in the cart, not only from the group that changed:

* For the group that the buyer changes, send the handle of its new option.
* For every other group that has a selected option, send its current `selectedDeliveryOption.handle`. Leave out a group whose `selectedDeliveryOption` is `null`.

Also leave out a pickup group that the buyer doesn't change, because the cart saves the store that you send and can select it again after the buyer picks another store in checkout. Do this in a cart with a subscription group too. The subscription's `SUBSCRIPTION` group and the `ONE_TIME_PURCHASE` group that holds its first delivery can each be a shipping group or a pickup group. Leave out each one that's a pickup group, unless the buyer changes it, and still send the current option of each one that isn't.

The following example selects the Express option for the shipping group from Step 1, and leaves out the pickup group, because the buyer doesn't change it. The mutation uses the `CartDeliveryGroupFields` fragment from Step 1, so send the fragment in the same request:

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL mutation

```graphql
mutation SelectDeliveryOption($cartId: ID!, $selectedDeliveryOptions: [CartSelectedDeliveryOptionInput!]!) {
  cartSelectedDeliveryOptionsUpdate(cartId: $cartId, selectedDeliveryOptions: $selectedDeliveryOptions) {
    cart {
      deliveryGroups(first: 10) {
        nodes {
          ...CartDeliveryGroupFields
        }
        pageInfo {
          hasNextPage
          endCursor
        }
      }
    }
    userErrors {
      field
      message
      code
    }
    warnings {
      code
      message
    }
  }
}
```

## Variables

```json
{
  "cartId": "gid://shopify/Cart/Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw?key=examplekey1234567890",
  "selectedDeliveryOptions": [
    {
      "deliveryGroupId": "gid://shopify/CartDeliveryGroup/d41d8cd98f00b204e9800998ecf8427e?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw",
      "deliveryOptionHandle": "e3b0c44298fc1c149afbf4c8996fb924"
    }
  ]
}
```

***

## Step 5: Read the cart again after checkout

In checkout, a buyer can change the cart's delivery groups. For example, the buyer can choose pickup for some items, choose a store, or choose another shipping option. When the buyer returns to your storefront or app, query the cart again from the Storefront API, not your GraphQL client's cache. Show the groups that checkout saved, so that your storefront doesn't overwrite the buyer's choices. If the buyer completed checkout, then the query usually returns `null` for the cart, because Shopify deletes a cart when its checkout completes. If the deletion fails, then Shopify tries again later, so the query can return the cart for a short time.

***

## Limitations

* When checkout ships the one-time purchase items in several shipments to one address, it saves them to the cart as one shipping group. That group has at most one delivery option, which combines the rates that checkout selected for those shipments. If a shipment doesn't have a selected option and a price yet, then the group has no options and its `selectedDeliveryOption` is `null`, so show the delivery cost as not calculated yet. The combined option goes away when the cart calculates its delivery options again, for example after a cart mutation. The group's options, selected option, and cost can then change.
* When checkout ships the one-time purchase items in several shipments to more than one address, the cart has no delivery groups, not even a pickup group or a subscription group. Show the delivery cost as not calculated yet.
* A cart has at most one pickup location. Every pickup item in the cart is picked up at the same store.
* A cart gets a pickup group only after the buyer chooses a store. A pickup group without a store isn't in `deliveryGroups`.
* When a cart has a pickup group and items to ship, but no shipping address, the cart's shipping group isn't in `deliveryGroups`, and the pickup group can have no delivery options yet.

***

## Update an existing integration

Your queries keep working, because pickup groups use the existing `Cart.deliveryGroups` schema. The data that they return can change. The following example shows the delivery groups of a cart before and after a buyer chooses, in checkout, to pick up one of its two items. The [table of patterns](#patterns-to-check) after the example lists what to check in your integration.

## Before checkout

```json
{
  "deliveryGroups": {
    "nodes": [
      {
        "id": "gid://shopify/CartDeliveryGroup/5f4dcc3b5aa765d61d8327deb882cf99?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw",
        "groupType": "ONE_TIME_PURCHASE",
        "cartLines": {
          "nodes": [
            { "id": "gid://shopify/CartLine/2f9c3b1e-7a4d-4e8b-9c6f-1d2e3f4a5b6c?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw" },
            { "id": "gid://shopify/CartLine/8e7d6c5b-4a39-4281-b7c6-d5e4f3a2b1c0?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw" }
          ]
        },
        "deliveryAddress": {
          "id": "gid://shopify/MailingAddress/0?model_name=Address",
          "address1": "150 Elgin St",
          "city": "Ottawa"
        },
        "selectedDeliveryOption": {
          "title": "Standard",
          "deliveryMethodType": "SHIPPING"
        }
      }
    ]
  }
}
```

## After checkout

```json
{
  "deliveryGroups": {
    "nodes": [
      {
        "id": "gid://shopify/CartDeliveryGroup/0b7e2a9f4c1d8e36a5f0c2b9d4e7a1c3?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw",
        "groupType": "ONE_TIME_PURCHASE",
        "cartLines": {
          "nodes": [
            { "id": "gid://shopify/CartLine/2f9c3b1e-7a4d-4e8b-9c6f-1d2e3f4a5b6c?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw" }
          ]
        },
        "deliveryAddress": {
          "id": "gid://shopify/MailingAddress/3?model_name=Location",
          "address1": null,
          "city": null
        },
        "selectedDeliveryOption": {
          "title": "Downtown store",
          "deliveryMethodType": "PICK_UP"
        }
      },
      {
        "id": "gid://shopify/CartDeliveryGroup/d41d8cd98f00b204e9800998ecf8427e?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw",
        "groupType": "ONE_TIME_PURCHASE",
        "cartLines": {
          "nodes": [
            { "id": "gid://shopify/CartLine/8e7d6c5b-4a39-4281-b7c6-d5e4f3a2b1c0?cart=Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw" }
          ]
        },
        "deliveryAddress": {
          "id": "gid://shopify/MailingAddress/0?model_name=Address",
          "address1": "150 Elgin St",
          "city": "Ottawa"
        },
        "selectedDeliveryOption": {
          "title": "Standard",
          "deliveryMethodType": "SHIPPING"
        }
      }
    ]
  }
}
```

After checkout, the cart has two one-time purchase groups, the pickup group comes first, and the shipping group has a new ID.

### Patterns to check

| Pattern | What happens with a pickup group | What to do instead |
| - | - | - |
| Query `deliveryGroups(first: 1)`, or read only the first group. | Your storefront misses a group, or treats the pickup group as the shipping group. | Query every group, and handle each one. Refer to [Step 1](#step-1-query-every-delivery-group). |
| Treat every group as a shipping group. | Your storefront shows stores as shipping options. | Check the `deliveryMethodType` of each group's `selectedDeliveryOption`. Refer to [Step 2](#step-2-identify-each-groups-delivery-method). |
| Show `deliveryAddress` as the address that items ship to. | Your storefront shows an empty address for the pickup group, or an address that its items don't go to. | Show the selected store for a pickup group. Refer to [Step 3](#step-3-show-each-group-to-the-buyer). |
| Copy `deliveryAddress` into `cartDeliveryAddressesAdd` or the buyer identity. | An address that has only an `id` fails address validation, and a pickup group's address doesn't say where the items go. | Copy addresses only from shipping groups. |
| Assume one `ONE_TIME_PURCHASE` group, or one selected option for the cart. | Your storefront shows or selects the wrong group's option, or a wrong delivery cost. | Select an option for each group. Refer to [Step 4](#step-4-select-a-delivery-option-for-each-group). |
| Leave out the current option of a group that the buyer doesn't change. | The cart can drop that group's selection. | Send the current option of each group that the buyer doesn't change, except a pickup group. Refer to [Step 4](#step-4-select-a-delivery-option-for-each-group). |
| Store delivery group IDs, or reuse them after checkout. | The IDs no longer match the cart's groups. | Query the cart again after checkout. Refer to [Step 5](#step-5-read-the-cart-again-after-checkout). |

If your app also has a [Discount Function](https://shopify.dev/docs/api/functions/latest/discount) whose delivery options target reads `cart.deliveryGroups`, or a [Cart and Checkout Validation Function](https://shopify.dev/docs/api/functions/latest/cart-and-checkout-validation) that reads it, then check each group's delivery method there too, instead of reading the first group. These Functions also run during Storefront API cart mutations, so they get the pickup group there as well as in checkout. For more information, refer to [About split carts in checkout](https://shopify.dev/docs/apps/build/orders-fulfillment/split-carts).

***

## Next steps

* Learn how to [create and update a cart](https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/cart/manage) with the Storefront API.
* Learn how to [support local pickup](https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/products-collections/local-pickup) on a custom storefront.
* Learn how [split carts affect orders and fulfillment orders](https://shopify.dev/docs/apps/build/orders-fulfillment/split-carts) after checkout.
* Report a problem with delivery groups in the [Storefront API feedback discussions](https://github.com/Shopify/storefront-api-feedback/discussions).

***
