Product Upsell For 7.0


Description

Redirect customers to an upsell page after they add an item to the cart. This plugin uses code injection and works with Squarespace 7.0 (Brine template family).


How To Install

From your Squarespace account, go to Site Code Injection. 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 -->

Customize

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.

Express Checkout in the checkout settings must be disabled for the redirect to work.


Previous
Previous

Second Color On Hover Button

Next
Next

Text Outline Effect