Retrieve the checkoutId to use it in checkoutDiscountCodeApplyV2

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)

Shopify Staff
1440 235 489

Hey @jesusaguiar , that's a great question. 


You can get the checkout ID from the response of the createCheckout mutation 


Another place is to query the customer for last incomplete checkout 


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 or the Shopify Web Design and Development Blog