hello community!
When using the addToCart() the code works well and the mini cart open but there is no product in it, just after i refresh the page i can see the product.
function addToCartRelated(selectedVariant, selectedItemId) {
$w('#loadingCheckOutIcon').show()
$w('#addToCart').disable()
const options = {
"lineItems": [{
"catalogReference": {
// Wix Stores appId
"appId": "1380b703-ce81-ff05-f115-39571d94dfcd",
// Wix Stores productId
"catalogItemId": selectedItemId,
"options": {
// Wix Stores variantId
"variantId": selectedVariant
}
},
"quantity": 1
}]
};
myAddToCurrentCartFunction(options)
.then((updatedCurrentCart) => {
const cartId = updatedCurrentCart._id;
// const numberOfCartLineItems = updatedCurrentCart.lineItems.length;
$w('#loadingCheckOutIcon').hide()
$w('#addToCart').enable()
updateUserCarty(cartId)
console.log('Success! Updated cart:', updatedCurrentCart);
return updatedCurrentCart;
})
.catch((error) => {
console.error(error);
// Handle the error
});
}