In Tweakwise JS, an add-to-cart button can be added to the product tile. This button will not automagically add the product to the shopping cart: Tweakwise JS will trigger an event that can be used to implement the add-to-cart behavior.
Catching this add-to-cart event can be achieved through event hooks:
<script>
window["twn-starter-config"] = window["twn-starter-config"] || {};
window["twn-starter-config"].on = {
// ...
"twn.add-to-cart": function (event) {
var productId = event.data.itemno;
// use productId to add the selected product to the shopping cart
}
};
</script>
The function body can be implemented as required to place the selected product in the shopping cart.
Important: the snippet above is an example on how to overwrite Tweakwise JS configuration in your frontend. Read more about available options in our Options reference.