Hi there! I have an app which allows customers to apply discount codes on the cart page using the mutation “cartDiscountCodesUpdate” provided by Storefront API. This mutation needs cart id with the following template:
gid://shopify/Cart/<cart.token> where <cart.token> - I receive from a client by fetching the cart using AJAX api because there’s no other ways to do this. It works for development stores and for normal stores migrated to new checkout api or recently created stores already with new checkout api. It doesn’t work for old stores which are not migrated to the new checkout.
It doesn’t work because cartDiscountCodesUpdate mutation can’t find the card by id, it returns:
{
message: "The specified cart does not exist.",
errorCode: "INVALID"
}
And you know what? There’s no even such issue in the documentation of this mutation: https://shopify.dev/docs/api/storefront/2024-04/mutations/cartdiscountcodesupdate
There is INVALID code but the message is different: “The input value is invalid.”
And I also found that the cart token differs on stores with the new checkout and the old one:
Z2NwLWV1cm9wZS13ZXN0MTowMUhaRjZTRlg4RzlTOEZWWUdGUUNaWTA1UA - token format on the new checkout stores
01313bbad43e0354bd635585beb0dd1c - token format on the old checkout stores
Is there anything which can help me to apply discount codes using graphql mutation? Or maybe I can recreate an id of a cart? So any ideas please! ![]()