top of page

Forum Posts

Ryan Shafer
Aug 07, 2021
In Coding with Velo
I am trying to create a custom product page with dynamic pages. I ideally want the user to be able to click a button and add that product to their cart without being routed to Wix's pre-built product page. I am trying to code a normal button to make it work. I am new to Velo and javascript. I have researched a lot and no code that I have found in this forum has worked yet. Below are the codes that I have found/tried: Attempt #1 import wixData from 'wix-data'; export function dynamicDataset_ready(){let product =$w('#dynamicDataset').getCurrentItem();$w('#atcButton').onClick(()=>{$w('#shoppingCartIcon1').addToCart(product._id); })} Attempt #2 import wixData from 'wix-data'; export function addToshoppingCartIcon_click(event, $w) { const productId = $w('#dynamicDataset').getCurrentItem()._id; $w('#shoppingCartIcon1').addToCart(productId, 1, ); } Attempt #3 export function button1_click(event) { const productId = $w('#dynamicDataset').getCurrentItem()._id; $w('#shoppingCartIcon1').addToCart(productId); } I have tried a few other codes as well, but these seem the most promising based on others comments and my very basic knowledge of the code. Any help would be great!
1
13
918

Ryan Shafer

More actions
bottom of page