No deliveryGroups returned when adding a cart line item.

Topic summary

A developer is experiencing an issue with Shopify’s cart API in their Hydrogen app while attempting to estimate shipping costs.

The Problem:

  • After successfully adding a cart line item (which generates a cartId) and updating the buyer identity with country, province, and zip code via cartBuyerIdentityUpdate mutation, the deliveryGroups array consistently returns empty
  • The same cartId works perfectly when tested on the checkout page, where delivery groups populate correctly

What’s Working:

  • Cart line item creation
  • cartBuyerIdentityUpdate mutation executes successfully
  • Delivery address preferences are being set with postal code, country, and province code

Current Status:
The developer is seeking help to understand why deliveryGroups remain unpopulated in their implementation, despite providing all necessary address information. No solution has been identified yet.

Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

Hi !

I’m trying to get an estimate cost of shipping in my Hydrogen app.

For that, I add a cart line item, which creates a cartId.

  const result = await context.cart.addLines([
    {
      merchandiseId: variantId,
      quantity: 1,
    },
  ]);

I then mutate succesfully the “cartBuyerIdentityUpdate”, providing the country, province and zip code.

  const buyerIdentityResponse = await context.storefront.mutate(
    UPDATE_CART_BUYER_IDENTITY_MUTATION,
    {
      variables: {
        cartId,
        buyerIdentity: {
          countryCode,
          deliveryAddressPreferences: [
            {
              deliveryAddress: {
                zip: postalCode,
                country: country,
                province: provinceCode,
              },
            },
          ],
        },
      },
    },
  );

But it always returns an empty array for deliveryGroups.
When I try the same cartId in the checkout page, it works perfectly.

Am I missing something ? Any idea why deliveryGroups would come back unpopulated everytime ?

Thanks for your help !