addToCart : System Error

Question:
What is the solution to this error: “Error adding to cart: Error: System error occurred, request-id: 1705960864.833138354884661962”

Product:
Wix Editor

What are you trying to achieve:
I am trying to create a custom product page with an element called #addToCart. When I click #addToCart it is calling the backend addToCart function.

What have you already tried:
I’ve tried using the frontend addToCart function and the backend createCart function but still having this issue, or the cart is created with the array = 0.

Additional information:
Here is my code:

import { cart } from ‘wix-stores-frontend’;
import { myAddToCartFunction } from ‘backend/addToCartBackend.jsw’;
import { myGetCartFunction } from ‘backend/getCartBackend’;
import { myCreateCartFunction } from ‘backend/createCartBackend’;
import { product } from ‘wix-stores-frontend’;
import wixEcomBackend from ‘wix-ecom-backend’;

const productId = “f04d9cb2-8c97-31a1-6841-022fa8664724”;

$w.onReady(function () {
// Set the initial quantity to 1
$w(“#qty1”).text = “1”;

// Decrease button click event
$w(“#decr1”).onClick(() => {
updateQuantity(-1);
});

// Increase button click event
$w(“#incr1”).onClick(() => {
updateQuantity(1);
});

// Add to cart button click event
$w(‘#addToCart’).onClick(() => {
const options = {
“lineItems”: [{
“catalogReference”: {
“appId”: “215238eb-22a5-4c36-9e7b-e7c08025e04e”,
“catalogItemId”: “a41a873c-28d2-4f23-76fd-4b45fa6bfa49”
},
“quantity”: parseInt($w(‘#qty1’).text, 10)
}]
};

console.log('Attempting to add to cart with options:', options);

myAddToCartFunction(options)
  .then((updatedCart) => {
    console.log('Success! Updated Cart:', updatedCart);
    // Check if the item is added to the cart
    if (updatedCart.lineItems.length > 0) {
      console.log('Item added to the cart successfully.');
    } else {
      console.error('Error: Item not added to the cart.');
    }
    return updatedCart;
  })
  .catch((error) => {
    console.error('Error adding to cart:', error);
  });

});

function updateQuantity(change) {
// Get the current quantity from the text element
let currentQuantity = parseInt($w(“#qty1”).text, 10);

// Ensure the quantity is at least 1
currentQuantity = Math.max(1, currentQuantity + change);

// Update the text element with the new quantity
$w("#qty1").text = currentQuantity.toString();

}
});

Okay so i got it to work no errors. but the only problem now is,
the array in wix dev console is showing that cart got products added successfully.
the array in live browser console is showing that no products were added to the cart successfully.

how do i fix this?

1 Like

bump.

please help. not sure what to do to resolve this issue.

1 Like

bump.2

please help. not sure what to do to resolve this issue.

1 Like

Did you find a fix? I’m struggling with this tol