I’m creating a product page template using dynamic pages. I’m using custom code to get the current product id, and a normal button with an onClick addToCart function to add it to the cart.
However, I’m getting the following error:
Unhandled promise rejection FetchError : [object Object]
Here is the code I’m using:
export async function addToCartBtn_click(event, $w) {
var product = $w(“#dynamicDataset”).getCurrentItem()._id;
await $w(‘#shoppingCartIcon2’).addToCart(product);
}
(I have also tried it without the async/await, but it still has the same error)
Would anyone be able to shed any light on why this isn’t working? I’ve read multiple posts in the forum of people experiencing similar/the same thing, but none of them seem to have been resolved.
Thanks, any help would be great.