Do I need to add any component tags to a non-product/catalogue page so that the buy now and add to cart buttons work? I am wanting to use something like -
{% component itemId: "3912", type: "ecommerce_buy_now" %}
To add a specific product to the shopping cart.
You’ll probably need to add the product specific JSON data for the required eCommerce Javascript - which is included as a property of the product (ie: this.ProductDataJsonHTML
).
However, if it’s not a product page, or you are not already calling a specific Product, you’d need to add the Product component in order to get this data.
For example:
{% component type: "module", source: "Products", layout: "", filterBy: "id", filterValue: "<YOUR PRODUCT ID>", collectionVariable: "myProduct" %}
and then to output the JSON data:
{{myProduct.items[0].ProductDataJsonHTML}}