In reference to this documentation: getCheckout( ) : Get Checkout | Velo
I can’t retrieve the checkout details using getCheckout(), but I am able to create checkoutId from this function createCheckoutFromCurrentCart( ) :
//Create checkout from current cart
myCreateCheckoutFromCurrentCartFunction(checkoutOptions)
.then((checkoutId) => {
console.log("Success! Checkout created, checkoutId:", checkoutId);
//Get checkout details
myGetCheckoutFunction(checkoutId)
.then((checkout) => {
console.log("Success! Retrieved checkout:", checkout);
return checkout;
})
.catch((error) => {
console.error(error);
// Handle the error
});
return checkoutId;
})
.catch((error) => {
console.error(error);
// Handle the error
});
My suspicion here is that even though your promise for create checkout has returned, the checkout is not yet available immediately for the getCheckout function. I would test with a setTimeout here just to test that theory and see if it’s “not ready” yet.
Alternatively if you think you may be experiencing a bug, you can report through this flow Wix Studio - How to report a bug
Hi, the myGetCheckoutFunction won’t render anything even after setting the timeout.
//Create checkout from current cart
myCreateCheckoutFromCurrentCartFunction(checkoutOptions)
.then((checkoutId) => {
console.log("Raw checkoutID:", checkoutId);
const finalCheckoutID = checkoutId.checkoutId;
console.log("Success! Checkout created, extracted checkoutId:", finalCheckoutID);
setTimeout(() => {
console.log("Calling myGetCheckoutFunction with checkoutId:", finalCheckoutID);
// Get checkout details after waiting
myGetCheckoutFunction(finalCheckoutID)
.then((checkout) => {
console.log("Success! Retrieved checkout:", checkout);
// Continue with checkout flow
})
.catch((error) => {
console.error("Failed to get checkout:", error);
// Handle the error
});
}, 5000); // 5 second delay
return checkoutId;
})
.catch((error) => {
console.error(error);
// Handle the error
});