Learn how to subscribe to events fired by Tolstoy widget.
window.tolstoyWidget
is already initialized or wait for the tolstoyWidgetReady
event before doing anything. This will make sure Tolstoy’s widget is set for action:
onClick
event like so:
Subscribe to event tolstoy_product_card_click
will appear in your logs.
myCallback
will be triggered with the following payload:
tolstoy_product_card_click
event prevents the product modal from opening:
window.tolstoyWidget.subscribe
:
onClick
event like so:
Subscribe to event tolstoy_add_to_cart
will appear in your logs.
myCallback
will be triggered with the following payload:
payload
to be sent back within the message, so make sure to spread payload
in your message.
🛈 Note 2: The description
field is optional. Use it to specify an error like itemSoldOut
. If you skip it, you’ll get a general “Error adding to cart” message.
myCallback
should be the original callback passed to window.tolstoyWidget.subscribe