Hi there, people. Does anyone know how to fetch the appId or any workarounds on how to create a Cart if none exists?
based to this code example from Velo documentation:
const options = {
lineItems: [{
catalogReference: {
// appId for Wix Stores Catalog
appId: "1380b703-ce81-ff05-f115-39571d94dfcd",
// example of Wix Stores productId
catalogItemId: "c8539b66-7a44-fe18-affc-afec4be8562a"
},
quantity: 3
}]
}
try {
const newCart = await cart.createCart(options);
console.log('Success! Created newCart:', newCart);
return newCart;
} catch (error) {
console.error(error);
// Handle the error
}
URL REFERENCE : https://www.wix.com/velo/reference/wix-ecom-backend/cart/createcart
My flow:
I am trying to save the productId from Product Page when the add to cart button is clicked. I have a custom method in my backend that will check if the cart exists first. If it exists, then productId will be saved together with the cartId and if it is not exist, then I need to create a new cart with the current item that the customer is trying to add to cart and save the same keys as well after creating a cart.
Hi Tim,
The app ID's for Wix apps are fixed values, you can learn more here: https://dev.wix.com/docs/develop-websites/articles/wix-apps/about-apps-made-by-wix Generally you can use the add to current cart API's for simple eCom implementations: https://www.wix.com/velo/reference/wix-ecom-backend/currentcart Does the system you are creating require multiple carts per user? What is the use case? Eitan