PROBLEM:
Hi, i’m using createCheckoutFromCurrentCart(), in reference to docs: Create Checkout From Current Cart | Velo
And i’m getting this error message, can you please tell me how to solve this problem, am i missing something in the checkout options?
Message
message: 'Cart not found: Cannot find cart by ownership'
details:
applicationError:
description: Cannot find cart by ownership
code: OWNED_CART_NOT_FOUND
data: {}
backend/createCheckout.web.js
import { currentCart } from "wix-ecom-backend";
//Creating checkout ID From the current cart
export const myCreateCheckoutFromCurrentCartFunction = webMethod(
Permissions.Anyone,
async (options) => {
try {
const checkoutId =
await currentCart.createCheckoutFromCurrentCart(options);
return checkoutId;
} catch (error) {
console.error(error);
// Handle the error
}
},
);
Page code
import { myCreateCheckoutFromCurrentCartFunction } from "backend/createCheckout.web.js";
//Checkout options
const checkoutOptions = {
// channelType is a required field
billingAddress: order.description.billingAddress,
channelType: "WEB",
email: order.description.shippingAddress.email || order.description.billingAddress.email,
shippingAddress: order.description.shippingAddress,
};
//Create checkout from current cart
myCreateCheckoutFromCurrentCartFunction(checkoutOptions)
.then((checkoutId) => {
console.log("Success! Checkout created, checkoutId:", checkoutId);
})
.catch((error) => {
console.error(error);
// Handle the error
});