Skip to content

Instantly share code, notes, and snippets.

@cpv123
Last active October 5, 2021 04:59
Show Gist options
  • Save cpv123/ccd3957079087c9441d786cee84c6ba6 to your computer and use it in GitHub Desktop.
Save cpv123/ccd3957079087c9441d786cee84c6ba6 to your computer and use it in GitHub Desktop.
const handleAddToCart = async () => {
try {
const { cart } = await commerce.cart.add(product.id, quantity)
setCart(cart)
plausible("addProductToCart", {
props: {
productName: product.name,
}
})
} catch (error) {
plausible("addProductToCartError", {
props: {
productName: product.name,
error: error.message,
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment