New Shopify Certification now available: Liquid Storefronts for Theme Developers

Storefront Cart API (2022-07 RC) - cartDiscountCodesUpdate not working as expected

Solved
steveb3210
Shopify Partner
7 1 1

It appears that when I try to apply a discount code via cartDiscountCodesUpdate

 

- The code is applied

- The code is returned in Cart.discountCodes

 

However, Cart.discountCodes[0].applicable is set to false but the total for the cart has changed to reflect the applied discount.

 

I'm applying a 10% Off coupon and my query looks like this:

 

 

  mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]!, $contextCountry: CountryCode!) @inContext(country: $contextCountry) {
    cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
      cart {
        ...CartFragment
      }
      userErrors {
        field
        message
      }
    }
  }

 

 

 

I should also add, the documentation here has the wrong method signature:

https://shopify.dev/api/storefront/2022-01/mutations/cartDiscountCodesUpdate

 

 

Thanks,

Stephen

 

Accepted Solution (1)
_JCC_
Shopify Staff
Shopify Staff
200 27 55

This is an accepted solution.

Hi @steveb3210 , 

 

I just wanted to follow up to let you know an issue has been created on our end to address the applicable issue noted with discount codes. I can't share any timelines on when the issue will be resolved but can update you when I know more.

 

I've also reached out to the docs team about the code sample having the error so we'll get that taken care of as well.

 

Regards,

John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me 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

View solution in original post

Replies 2 (2)
_JCC_
Shopify Staff
Shopify Staff
200 27 55

This is an accepted solution.

Hi @steveb3210 , 

 

I just wanted to follow up to let you know an issue has been created on our end to address the applicable issue noted with discount codes. I can't share any timelines on when the issue will be resolved but can update you when I know more.

 

I've also reached out to the docs team about the code sample having the error so we'll get that taken care of as well.

 

Regards,

John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me 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

steveb3210
Shopify Partner
7 1 1

< Nevermind, the API changed to handle different types of allocations >