Revy Upsell - Callbacks

The app Unlimited Smart Upsell Offers by Revy Apps has some javascript functions that run when specific actions happen within the app, these functions are called callbacks and were created to help merchants and their developers implement custom behaviors like Cart Drawer/Mini Cart Refresh or any other behavior that should happen after a specific app action.

To implement these callbacks you have to add the callback javascript code after the app script in your Shopify Theme. 

We do recommend adding the callbacks in the ending of the file snippets/revy-upsell-script.liquid, this way you have all the code related to the Upsell App inside just one file.

To implement a callback use a code like this:

   <script>
      window.revyUpsellDataLayer = window.revyUpsellDataLayer || [];
      window.revyUpsellDataLayer.push({onCartChangeCallbacks: function() {
        console.log('onCartChangeCallbacks Callback running!');
	console.log("YOUR CODE RUNS HERE");
      }});
    </script>

In the example above the callback implemented was the "onCartChangeCallbacks", which runs when the cart change.

Callbacks List

onLoad

This callback runs as soon as the app loads in your store, not when the popup shows but when the app finish loading, don't matter if an offer is showing or not.

   <script>
      window.revyUpsellDataLayer = window.revyUpsellDataLayer || [];
      window.revyUpsellDataLayer.push({onLoad: function() {
        console.log('onLoad Callback running!');
	console.log("YOUR CODE RUNS HERE");
      }});
    </script>

onNoneOfferCallbacks

This callback runs when a product is added to the cart but there is no offer available for this product, if you are using the app setting to redirect if none offer found this callback will run very quickly and then redirects, it is more recommended for merchants that choose to not redirect to cart if the product added to cart has no offer available, it is generally used to refresh Mini/Cart Drawers on those cases.

   <script>
      window.revyUpsellDataLayer = window.revyUpsellDataLayer || [];
      window.revyUpsellDataLayer.push({onNoneOfferCallbacks: function() {
        console.log('onNoneOfferCallbacks Callback running!');
	console.log("YOUR CODE RUNS HERE");
      }});
    </script>

onShowPopupCallbacks

Runs when the Upsell popup shows.

   <script>
      window.revyUpsellDataLayer = window.revyUpsellDataLayer || [];
      window.revyUpsellDataLayer.push({onShowPopupCallbacks: function() {
        console.log('onShowPopupCallbacks Callback running!');
	console.log("YOUR CODE RUNS HERE");
      }});
    </script>

onAddToCartCallbacks

Runs when an Upsell product is added to the cart using the app's popup.

   <script>
      window.revyUpsellDataLayer = window.revyUpsellDataLayer || [];
      window.revyUpsellDataLayer.push({onAddToCartCallbacks: function() {
        console.log('onAddToCartCallbacks Callback running!');
	console.log("YOUR CODE RUNS HERE");
      }});
    </script>

onCalculateCartTotal

Runs when the total inside the popup changes, this can happen in 2 cases, when the popup opens, and when an item is added to the cart inside the popup. 

   <script>
      window.revyUpsellDataLayer = window.revyUpsellDataLayer || [];
      window.revyUpsellDataLayer.push({onCalculateCartTotal: function() {
        console.log('onCalculateCartTotal Callback running!');
	console.log("YOUR CODE RUNS HERE");
      }});
    </script>

onClosePopupCallbacks

Runs when the popup is closed manually, via the close button or clicking in the background (if these options are enabled).

   <script>
      window.revyUpsellDataLayer = window.revyUpsellDataLayer || [];
      window.revyUpsellDataLayer.push({onClosePopupCallbacks: function() {
        console.log('onClosePopupCallbacks Callback running!');
	console.log("YOUR CODE RUNS HERE");
      }});
    </script>

onCartChangeCallbacks

Runs when the cart changes, this callback is recommended to keep Cart Drawers/Mini Cart of themes updated.

   <script>
      window.revyUpsellDataLayer = window.revyUpsellDataLayer || [];
      window.revyUpsellDataLayer.push({onCartChangeCallbacks: function() {
        console.log('onCartChangeCallbacks Callback running!');
	console.log("YOUR CODE RUNS HERE");
      }});
    </script>

If you need a hand or have questions regarding Upsell App Callbacks please let us know at [email protected], I will be happy to help ;)

Still need help? Contact Us Contact Us