Wix adding to custom cart "Error adding to cart message: 'item with not requested catalogReference returned: Internal Server Error'

I’m having trouble with
I have been experiencing issues when adding to or removing items from cart, using a custom catalog that I have built, utilizing the Velo Tutorial: eCommerce Catalog Service Plugin, “wix-ecom-backend” and “wix-ecom-frontend” APIs. I am getting an error message, which seems to be generated in the backend file (backend/getCart.web.js). The error message I am getting is: ‘Error removing from cart message: 'item with not requested catalogReference returned: Internal Server Error' or sometimes Error adding to cart message: 'item with not requested catalogReference returned: Internal Server Error'. I am not sure if this maybe causing the issue, but all my “Cart” code is coded into the wix’s native Cart page - the one that is created when you install wix stores. Strangely, these errors don’t always happen, but I encounter them more often when I add more than one item to my cart.

My remove item from cart is within a repeater, because each image, added to cart, gets its own properties. Here is the excerpt code for the repeater:

$item("#removeItemButton").onClick(async()=>{
  const cart = await removeItemFromCart([itemData._id])
  renderCart(cart)
  await wixEcomFrontend.refreshCart()

Here is the removeItemFromCart function:

export const removeItemFromCart = webMethod(
      Permissions.Anyone,
      async (lineItemIds) => {
         try {
           const updatedCurrentCart = await
             currentCart.removeLineItemsFromCurrentCart(lineItemIds);
           console.log("Success! Line items removed from cart:",                    updatedCurrentCart);
           return updatedCurrentCart.cart;
         } catch (error) {
             console.error("Error removing from cart",error)}
         }
);

Working in
I am working in Wix Studio, but also tried the wix editor. I confirm that the errors are present in both editors.

Site link
I am not sure how my website link could be helpful, but here it is: https://abedinyabedin.wixstudio.com/testwebsite

If you go to my portfolio and add an image to that cart by first choosing an image configuration (print option and size) and then adding a second image, if you try to remove the items from cart, you will most likely see that the images cannot be removed. That is when I get the error: ‘Error removing from cart message: 'item with not requested catalogReference returned: Internal Server Error'

What I’m trying to do
My goal is to have a responsive site - when I click addToCart or remove item from cart buttons, sometime everything works just fine, but sometimes the item is not added or removed from cart.

What I’ve tried so far
I have tried debugging my code by looking at the Velo eCome API documentation, but just can’t figure out why this error even happens. Judging by the error message, I assume what is happening is when I hit that remove button for the particular item, wix fails to obtain the ItemID of the image I am trying to remove from Cart, although the remove function is a asynchronous function.

Extra context
Attached are images of wix logs and my cart page, demonstrating the issue. Any help will be highly appreciated!

1 Like