Listening for Smart Cart Events

Below are the events that trigger within the Smart Cart lifecycle. Since the Smart Cart is an extension of the cart object, many of the Cart events can be used to help aid additional functionality such as the 'rebuy:cart.change' event if something needs to be updated conditionally on items that are or are not in the cart.

You are also able to access these events in the form of anonymous function is the Smart Cart settings under the "Advanced" section at the bottom of the settings page. This way there is no need for theme code changes and these functions can be turned on or off with the click of a button.

May developers have used these to provide additional DOM manipulation/creation without the need for a Smart Cart custom template. You can also manipulate the Smart Cart settings if needed as well by adjusting the data within the Smart Cart function

Init

The init event is the first event that is triggered of the Smart Cart lifecycle.

document.addEventListener('rebuy:smartcart.init', function(event){
    console.log('rebuy:smartcart.init event', event.detail);
});

Ready

The "ready" event is triggered once the Smart Cart has fully initialized and everything is ready to run.

document.addEventListener('rebuy:smartcart.ready', function(event){
    console.log('rebuy:smartcart.ready event', event.detail);
});

Show

This event is triggered whenever the show function is called. window.Rebuy.SmartCart.show();

document.addEventListener('rebuy:smartcart.show', function(event){
    console.log('rebuy:smartcart.show event', event.detail);
});

Hide

This event is triggered whenever the hide method is called. window.Rebuy.SmartCart.hide();

document.addEventListener('rebuy:smartcart.hide', function(event){
    console.log('rebuy:smartcart.hide event', event.detail);
});