lineItems is empty when first adding item to custom cart

Hello,

I have created a custom cart in Wix Studio, using Velo, and I am trying to add my first item to the cart. Then, I console.log(updatedCart) but the lineItems= seems to be empty.

Here is my backend code:

import { Permissions, webMethod } from “wix-web-module”;
import { cart, currentCart, checkout } from “wix-ecom-backend”;
const APP_ID = “b351bf5a-910d-40af-88c0-4bf36b984ab0”
export const addToCart = webMethod(
Permissions.Anyone,
async (params) => {
console.log("CatalogItemId is: ", params.imageID)
const options = {
lineItems: [
{
catalogReference: {
appId: APP_ID,
catalogItemId: params.imageID,
options: params.imageConfig,
},
quantity: 1,
},
],
};
console.log(“Cart params=”,options)
try {
const updatedCart = await currentCart.addToCurrentCart(options);
const newcart = await currentCart.getCurrentCart()
console.log(“Updated Cart”,newcart)
return updatedCart;
} catch (error) {
console.log(“Error adding to cart”, error)
}
}

And here is where I invoke the backend code:

$w("#addToCartButton").onClick(()=>{
            addImageToCart(imageId, imageOptions)
})
    const addImageToCart = (async(imageId, imageConfig) => {
        //* Add the image to cart
const options = {"imageID":imageId, "imageConfig":imageConfig}
console.log("imageConfig =", imageConfig.Material, imageConfig.Size)
const updatedCart = await addToCart(options)
console.log("UpdatedCart = ", updatedCart)
})

And lastly, here is the output from the console.log:

Updated Cart {"lineItems":[],"buyerInfo":{"visitorId":"d47e06be-a80d-4f3b-9ab7-fc73f178a8e0"},"currency":"CAD","conversionCurrency":"CAD","buyerLanguage":"en","siteLanguage":"en","taxIncludedInPrices":false,"weightUnit":"KG","subtotal":{"amount":"0","convertedAmount":"0","formattedAmount":"C$0.00","formattedConvertedAmount":"C$0.00"},"subtotalAfterDiscounts":{"amount":"0","convertedAmount":"0","formattedAmount":"C$0.00","formattedConvertedAmount":"C$0.00"},"discount":{"amount":"0","convertedAmount":"0","formattedAmount":"C$0.00","formattedConvertedAmount":"C$0.00"},"appliedDiscounts":[],"purchaseFlowId":"a3875624-ff33-47e4-8d68-d6dfe38594ab","paymentCurrency":"CAD","managedByV2":false,"_id":"e38a3112-c04b-401c-ac7c-220353351c55","_createdDate":"2025-08-17T18:52:28.017Z","_updatedDate":"2025-08-17T20:19:28.150Z"}

Any idea why lineItems would be empty list?

1 Like

there could be a few reasons.

  1. Check the app ID is correct. For Stores items it must be the Stores app ID - About Apps Made by Wix
  2. catalogItemId must be the Stores productId (e.g. from products.getProduct()), not a media/image ID.
  3. If your image is not a Wix Stores catalog item, you can’t add it with a Stores catalogReference.
1 Like

Hi @Dan_Suhr ,

You are right! The issue was the appID was wrong. After fixing that, now I can see the added item in the lineItems :slight_smile:

Oh, and I am using a custom catalog from a collection of images I have i.e. I am utilizing the wix-ecom-backend API

Thank you so much for your help!

Cheers,

Abedin

2 Likes