Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi,
I'm trying to utilize the Cart GraphQL API to create a cart with selected products and display all available shipping methods. I've made the appropriate query, everything is generating, however, there's a discrepancy between the methods in the API and the methods in the Checkout.
The Cart API doesn't return shipments from the Carrier Service API. How can this be worked around?
Query:
mutation cartCreate($input: CartInput) { cartCreate(input: $input) { cart { id createdAt checkoutUrl deliveryGroups(first: 100) { nodes { deliveryOptions { code deliveryMethodType title description estimatedCost { amount currencyCode } } } } } userErrors { field message } } }
Response:
{ "data": { "cart": { "id": "gid://shopify/Cart/c1-455ed6f80eea2bf872c08d7cb5419128", "createdAt": "2024-03-31T19:39:11Z", "deliveryGroups": { "nodes": [ { "deliveryOptions": [ { "code": "Test", "deliveryMethodType": "SHIPPING", "title": "Test", "description": "", "estimatedCost": { "amount": "1.0", "currencyCode": "PLN" } } ] } ] } } } }
Screen from Checkout:
This was implemented in CartAPI in 2024-07 version. You can read about it more here: https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/defer#fetching-carrie...