top of page

Dynamic Add-to-Cart Button for Custom E-commerce Stores



Velo Code:


import { cart } from 'wix-stores';

export function addToCart_click(event) {
    let product = $w('#dynamicDataset').getCurrentItem();
    let idProduct = product.productReference;

    $w('#shoppingCartIcon1').addToCart(idProduct)
        .then(() => {
            console.log("Product Added");
            cart.showMiniCart();
        })
        .catch((error) => {
            console.log(error);
        });
}

Enjoy!

bottom of page