top of page

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

In this lesson, you will learn how to create a custom E-Commerce dynamic page with an Add-to-Cart button that adds the product from the dynamic page to the shopping cart.


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); }); }


Make sure you use the proper names that correspond with your elements on your page! Have Fun!


bottom of page