Hi, we are developing a webpush notification app for abandoned carts. For this, we need to capture the cart token on the front end so we can connect a checkout with a push subscription. Initially, we were able to capture the cart token by inserting a snippet with {{ cart | json }} and that JSON would have the token. Recently we are seeing that cart token is missing from this object. Even if items are added to the cart, the token doesn’t show up in the cart object.
Was there a recent change that has caused this? Is there another way to capture the cart token on the store frontend?
It’s disappointing the your original post was 2 weeks ago, yet there is no response from anyone at Shopify. If support calls are redirected to clients posting here then I’d hope a reply would come a bit sooner?
Thanks for the response. For reference, this is what we ended up doing as well.
It seems crazy to have to make another API call to get the cart - just to get the cart token, when the cart is already present (just without the token!).
The behaviour that recently changed on that liquid drop wasn’t listed in our documentation, so it’s not unexpected for undocumented behaviour to change without notice. Right now the best way to get the token is from cart.js as was already mentioned.
I agree that having the token available in the liquid drop is a better solution than having to make an AJAX call, I’ll bring this up with our teams to see whether it’s possible to have this added as an officially documented liquid attribute.
Just wanted to follow up here. I’ve received clarification that the token property was intentionally removed from the cart liquid drop object earlier this year. The decision to remove it was related to storefront performance and how our infrastructure handles caching, and was necessary to allow other projects to ship. It was removed without notice since it wasn’t documented to begin with, so for now the best way to get the token is through the AJAX call. I’ve provided feedback on the change either way, so our teams have this information for if/when there’s an opportunity to implement this again in the future.