We're creating an experience for a client wherein the customer pays for items from different vendors separately.
The customer adds products to their cart where they are grouped by vendor.
On the cart page, they click a checkout button for a given vendor, which fires a request to our integration that uses the API to create a draft order with that vendor's items, then redirects the customer to the invoice page.
The customer then completes the order for that vendor's items.
The problem we're facing is that when the customer completes the order, the entire cart is cleared – including the items they have not yet paid for.
Before we implement a workaround we have in mind, is there a way to prevent this functionality?
Solved! Go to the solution
Helo @SachaC can you please give me the source where did you get the information that the shopping cart is being cleaned by Shopify. Because I also see that the cart is now being emptied, but this was not the case before, and can't find any changelogs about this update
This is an accepted solution.
No source, unfortunately, we just realised when testing the implementation.
I haven't seen anything noted in a changelog, either, and we're almost certain we tested it a couple of months prior to starting the work.
Luckily, the client's store is on Shopify Plus, so our workaround is basically:
window.Shopify.Checkout.page === 'thank_you'
It's not ideal, but it works.
One thing that we noticed is that, sometimes, the ajax request would be fired too soon - that is, before Shopify had actually cleared the cart. We added a 2s delay after the "thank you" page has loaded to send the request which covers this.
Hope that helps.
Edit: I'm going to accept this message as a solution to the question, as it appears that there has been a change, but the above is a working workaround (providing it's a Plus store and you can edit the checkout.liquid file).