addToCart button on #ProductPage1

Hello,

I created my own custom product page and I just want to be able to add the current displayed product on #productPage1 to the cart. However I cannot get my code to work.

I am not using a dataset everything is coded.

let product; 
$w.onReady(async()=>{     
product =await$w('#productPage1').getProduct();})
}
});

export function addToCart_click(event) {
let productId = product._id;
$w("#shoppingCartIcon1").addToCart(productId)
}

Any Ideas on how to add the product that is currently shown on the product page?

Hello,

The issue you are experiencing seems to be related to incorrect syntax.

Remove the extra symbols in your onReady function as shown below:

let product;

$w.onReady(async function () {
product = await $w('#productPage1').getProduct();
});

Best regards!