I tried
addToCart and addProducts
The Promises pending time and very slow. After I clicked the Add to Cart Button, I need to wait 8-10 seconds for the product to appear on the mini-cart. Does anyone know why?
function getProductDetails() {
$w(“#productPage1”)
.getProduct()
.then((productInfo) => {
setProductTextInfo(productInfo);
$w(“#addcartbtn”).onClick(()=>{
console.log(“add to cart”)
if(Number.isInteger(parseFloat($w('#quantityInput').text))) {
$w("#shoppingCartIcon1").addToCart(productInfo._id, quantity, {"choices": productOptions, "customTextFields": []})
.then(() => {console.log("added");}).catch(e=>console.log(e))
}
});
$w("#addbutton").onClick(()=>{
let result = parseInt($w("#quantityInput").text ) + 1;
if(result <= 50) {
$w("#quantityInput").text = (parseInt($w("#quantityInput").text ) + 1).toString();
// console.log( (parseInt($w("#quantityInput").text ) + 1).toString());
}
});
$w("#minusbutton").onClick(()=>{
let result = parseInt($w("#quantityInput").text ) - 1;
if(result > 0) {
$w("#quantityInput").text = (parseInt($w("#quantityInput").text) - 1).toString();
}
});
})
.catch((error) => {
console.error(error);
});
}