Yes, you can react to various widget events using js.
To do this, on the Code tab in the widget's settings, set the Add code for handling widget callbacks flag.
The code of the widget will be added to the widget's code.
The added code outputs text to the console when various widget events occur.
Just replace the event handlers with your own.
The following events are available:
- INITIALIZED occurs when the widget is started.
- RESOURCE_GROUP_OPENED occurs when you open a group in the directory. It passes the parameters name and resourceGroupId.
- RESERVATION_STARTED occurs when you open a resource for booking. The name and resourceId parameters are passed to it.
- RESERVATION_SAVED occurs when you go from the reservation screen to the order screen. The name and resourceId parameters are passed to it.
- INDIRECT_ORDER_STARTED occurs when the form of payment appears and the payment is pending.
- ORDER_COMPLETED occurs when the order is successfully completed. Parameters orderNumber, total and deposit are passed to it.