Shopping cart JS events and triggers
- Ecommerce
"Before" Callbacks
"Before" callbacks could be used for additional custom js logic and could interrupt event process.
Process could be interupted via event.preventDefault(); function.
Syntax
document.addEventListener("CMS_BeforeExample", function(event) { var data = event.data; //custom code here });
List of callbacks (see release notes)
"After" Callbacks
"After" callbacks could be used in order to retrieve data that was returned from the server in order to apply any custom logic that may rely on it (for example custom shopping cart widget).
Syntax
document.addEventListener("CMS_AfterExample", function(event) { var data = event.data; //custom code here });
List of callbacks (see release notes)
Triggers
Triggers could be used in order to perform ecommerce action via JS instead of actual clicks or select actions on the html elements.
Syntax
var trigger = new Event('CMS_triggerExample'); trigger.data = {"param":"value"}; document.dispatchEvent(trigger);
List of triggers (see release notes)