Upsell Page

grey.png

Step One

From your Squarespace account, go to Code Injection: Settings > Advanced > Code Injection

Step Two

Copy and paste the code below into the Header Code Injection box.

<!-- Redirect to the Upsell Page after clicking on the Add To Cart button -->
<!-- Author: Dmitry Kiselyov @_dmitrykiselyov -->
<script>
function redirectToUpsellPage() {
  var upsellPageUrl = '/PAGE-URL-SLUG';
  var addToCartButton = document.querySelector('.sqs-add-to-cart-button');
  var productVariants = document.querySelector('.product-variants');

  function isVariantInStock() {
    return productVariants.getAttribute('data-variant-in-stock');
  }

  function onClick() {
    if (productVariants && isVariantInStock() || !productVariants) {
      setTimeout(function() {
        document.location.href = upsellPageUrl;
      }, 1000);
    }
  }

  if (addToCartButton) {
    addToCartButton.addEventListener('click', onClick);
  }
}

document.addEventListener('DOMContentLoaded', redirectToUpsellPage);
window.addEventListener('mercury:load', redirectToUpsellPage);
</script>
<!-- end Redirect to the Upsell Page after clicking on the Add To Cart button -->

Step Three

Change the PAGE-URL-SLUG in the code to the page’s url slug that you’d like customers to be redirect to. The url slug can be found in the page’s settings.

Save and refresh the page. 👍

Moov Labs