Associating carts with orders with `order.cart_token` deprecation

Hello,

The order.cartToken on both the REST and GraphQL admin APIs is marked for deprecation, however our apps depends on this to associate a checkout session with an order.

I’ve already opened a past topic about this in the old forums, but new partners haven’t been able to add to the thread. Seems like the old forums are transitioning to read-only.

Here’s the original topic

Summary

App Developers rely on the order.cartToken to associate pre-checkout or during checkout actions that customers make against orders after checkout.

Without this link, every single app will need to generate their own unique ID token of sorts and need to stuff it is a metafield, cart attribute or some other key-value store that’s available pre-checkout that carries over to the post-checkout order object.

We please ask that Shopify re-consider deprecating this crucial order.cartToken attribute, because it currently is the only standard for a unique identifier that tracks the checkout into a final order object.

2 Likes

+1 to this. Our app also fundamentally relies on the existence of a link between Checkout session and subsequent Order.

Would appreciate some guidance from Shopify on what could be done as relying on Metafields is a messy solution to something that was not a problem pre deprecation announcement.

This is a big deal for us too. One workaround I have been doing is searching through all orders with cart_token because thankfully that is still not deprecated but it is a very expensive query for stores with high order volume

const cartTokens = ['a', 'very', 'big', 'list', 'of', 'tokens'];
let hasNextPage = true;
while(hasNextPage) {
  const query = `{
      orders(first: 100, after: ${cursor ? `"${cursor}"` : "null"}, query:"${cartTokens
        .map((cartToken) => `cart_token:${cartToken}`)
        .join(" OR ")}") {
        pageInfo {
          hasNextPage
          endCursor
        }
        edges {
          node {
            createdAt
            totalPriceSet {
              shopMoney {
                amount
              }
            }
          }
        }
      }
    }`;
  const response = await api(query);
  hasNextPage = response.data.orders.pageInfo.hasNextPage;
}
1 Like

Thanks for sharing your workaround @Zarma_Charu , yes that is expensive computationally and for performance. Also, on high order volumes there’s a risk of the order being outside of the pagination limit.

Not trying to knock your method at all, just want to make it clear to the Shopify team of how this change is a huge detriment to apps that have any before checkout action that needs to be attributed to a specific order.

Can anyone at Shopify please provide a recommended path for us to move forward with the order.cartToken deprecation?

Are you expecting developers to somehow add metafields to the cart that will be transferred to the order? If so that’s only available to Plus stores using Checkout UI Extensions and that’s out of reach for most of merchants.

As far as I’m aware, the only metafield type system available is to stuff cart attributes which display in the Shopify Order Admin panel and are editable by end staff, not ideal for tracking with UUIDs. Every single app that performs a pre-checkout action will then need to leave their own bespoke UUID on every order.

I just want to make it clear how this deprecation is realistically affecting app developers. But I only have our side of the story because this thread hasn’t been responded to in either the Github, the merchant community forum or here. I would love to understand the logic behind this change and how we can adapt to it for a seamless transition for merchants.

1 Like

Appreciate your feedback and your challenges here Dylan - I’ve connected with the Orders product team to understand what their recommendation is here.

1 Like

Just wanted to update here - our team are aware of the gap here and will be addressing it. They’ve recommended that until there is a robust alternative in GraphQL you should continue using order.cartToken in the REST API.

3 Likes

You’re a rockstar @Liam-Shopify thank you so much for representing us! I’m relieved that we’re finally able to get our message across.

Looking forward to seeing what the solution is, and I’ll definitely help spread the word once there’s an official way of pre-checkout action/resource <> post-checkout order associations possible again.

+1 here :slightly_smiling_face:
We need this to support our post purchase upsell functionality

1 Like

Hey @Liam-Shopify - Does that mean we can continue using the current api (until there’s a standard robust solution with graphql) without worrying about the April 1 deprecation deadline? :slightly_smiling_face: