Dynamic Add-to-Cart Button for Custom E-commerce Stores
- Feb 14, 2022
- 1 min read
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!




Comments