Skip to main content

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.

Status: Completed3 comments

Log in to comment and vote

Comments3

  • Matt Walter changed status to Completed
    Team•

    Jul 9, 2020

  • Matt Jones changed status to In Progress
    •

    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');