How is this issue now possible? https://github.com/Shopify/js-buy-sdk/issues/98
What I've had to do is check if the orderStatusUrl isn't null (thus an order has been created) and if it isn't null then create a new checkout...
var checkoutID = sessionStorage.getItem('thisWebsiteCheckoutID');
client.checkout.fetch(checkoutID).then(function(checkout) {
if (checkout.orderStatusUrl === null || typeof(checkout.orderStatusUrl) == 'undefined') {
buildCart(checkout);
} else {
client.checkout.create().then(function(checkout) {
var checkoutID = checkout.id;
sessionStorage.setItem('thisWebsiteCheckoutID', checkout.id); // Store the ID in sessionStorage
buildCart(checkout);
});
}
console.log('checkout ↓');
console.log(checkout);
});
I had this exact same comment two days ago (when you posted this). What I did, was to re-fetch the cart on page load and on window.focus, (as the checkout link opens a new window, we can fairly safely assume the user will go away and come back). If the cart has an completedAt time, I then create a fresh new cart
@isjackwild Yours is perhaps more robust as using orderStatusUrl might become conflicting if you intend to use it further down the line.
Most helpful comment
I had this exact same comment two days ago (when you posted this). What I did, was to re-fetch the cart on page load and on window.focus, (as the checkout link opens a new window, we can fairly safely assume the user will go away and come back). If the cart has an completedAt time, I then create a fresh new cart