Event Listeners

Init

Triggers on widget initialization and passes the widget instance into the event details.

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

Before Ready

Triggers before the widget is ready and passes the widget instance into the event details.

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

Ready

Triggers when the widget is ready and passes the widget instance into the event details.

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

Before Add

Triggers before a product is added from a widget and passes the product to be added along with the widget instance into the event details.

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

Add

Triggers once a product is added from a widget and passes the product to be added along with the widget instance into the event details.

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

Before Remove

Triggers before a Gift With Purchase widget is going to remove an item from the cart because the rule is no longer valid for that product to be added. Or, when a customer removes a product from the Shopify checkout page or Recharge checkout page.

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

Remove

Triggers once a Gift With Purchase widget has removed an item from the cart because the rule is no longer valid for that product to be added. Or, when a customer removes a product from the Shopify checkout page or Recharge checkout page.

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

Before Change

Triggered before a widget makes a /change request to the Shopify cart. See the Change event for more details on when a change could happen.

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

Change

Triggered when a widget runs a /change request to the Shopify cart. A use case could be when the "Gift with Purchase" widget changes an item in the cart to align with the rules that have updated according to any change in the cart.

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

Before Decline

Triggers before the logic of declining an up-sell or cross-sell offering.

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

Decline

Triggers once the logic of declining an up-sell or cross-sell offering runs.

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

View

Triggers when a user clicks on a product or "Learn More" link from the widget. This could be clicking the product image, title or an actual learn more button/link.

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

Before Products Change

Triggers before the products that are being offered change. This is happens in cart based widgets as they will change the products being offered if a customer adds an item to the cart. This also triggers on initializing the widget as the widget goes from having zero products to having products.

document.addEventListener('rebuy.beforeProductsChange', function(event){
    console.log('rebuy.productsChange event', event.detail);
});

Products Change

Triggers once the products that are being offered change. This is happens in cart based widgets as they will change the products being offered if a customer adds an item to the cart. This also triggers on initializing the widget as the widget goes from having zero products to having products.

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

Refresh

Triggers whenever a widget refreshes.

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

Before Show

Triggers before a popup widget displays itself.

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

Show

Triggers once a popup widget displays itself.

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

Before Hide

Triggers before a popup widget hides itself.

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

Hide

Triggers once a popup widget hides itself.

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