eCommerce- Custom Callback function for successful Add to Cart
This is a request from Kalyani:
Is it possible to replace the default alert message when a Product is added to the Cart, with something more custom?
In this use-case they'd like to be able to redirect the customer straight to the Cart after the Product has been added. In another use case, they'd like to display the message in a different language.
Log in to comment and vote
Comments3
Jul 9, 2020
Released notes here -> https://help.siteglide.com/en/articles/3831674
Jul 7, 2020
Thanks for the tip Kirk!
The new feature will allow you to define a JS function to use on success.
Kirk Alvar
Jul 2, 2020
This can be achieved by overriding the alert function
window.nativeAlert = window.alert;
window.alert = msg => !!~msg.indexOf('Product added to cart') && window.nativeAlert('you custom message here');
window.alert = msg => !!~msg.indexOf('Product added to cart') && window.location.replace('/cart');