Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Retrieve the checkoutId to use it in checkoutDiscountCodeApplyV2

Retrieve the checkoutId to use it in checkoutDiscountCodeApplyV2

jesusaguiar
Shopify Partner
1 0 0

How can I know the checkoutId  to use it in checkoutDiscountCodeApplyV2? In the documentation the mutation has this form:

 

mutation checkoutDiscountCodeApplyV2($checkoutId: ID!, $discountCode: String!) {
  checkoutDiscountCodeApplyV2(checkoutId: $checkoutId, discountCode: $discountCode) {
    checkout {
      # Checkout fields
    }
    checkoutUserErrors {
      # CheckoutUserError fields
    }
  }
}

With these variables:

 

{
  "checkoutId": "",
  "discountCode": ""
}

Where do I find the checkoutId?

 

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 522

Hey @jesusaguiar , that's a great question. 

 

You can get the checkout ID from the response of the createCheckout mutation https://shopify.dev/docs/api/storefront/2023-10/mutations/checkoutCreate 

 

Another place is to query the customer for last incomplete checkout https://shopify.dev/docs/api/storefront/2023-10/objects/Customer#field-customer-lastincompletechecko... 

 

Hope that helps. 

 

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog