Product Upsell Page for 7.1

upsell.png

Description

Redirect to an upsell page after an item is added to the cart. This plugin uses code injection and works with Squarespace 7.1.


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 Upsell Page after clicking on Add To Cart Button -->
<!-- Author: Dmitry Kiselyov @_dmitrykiselyov -->
<script>
// /upsell-page is the default URL. To change it, replace /upsell-page with the required URL.
var upsellPageUrl = "/upsell-page"
////////////////////////////////
function redirectToUpsellPageHandler(wrapper){var addToCartButton=wrapper.querySelector(".sqs-add-to-cart-button"),productVariants=wrapper.querySelector(".product-variants");function isVariantInStock(){return productVariants.getAttribute("data-variant-in-stock")}function onClick(){(productVariants&&isVariantInStock()||!productVariants)&&setTimeout((function(){document.location.href=upsellPageUrl}),1200)}addToCartButton&&addToCartButton.addEventListener("click",onClick)}function redirectToUpsellPage(){var productPage=document.querySelector(".collection-type-products.view-item #productDetails, .collection-type-products.view-item .ProductItem-details"),productBlocks;productPage&&redirectToUpsellPageHandler(productPage),[].slice.call(document.querySelectorAll(".sqs-block-product")).forEach(redirectToUpsellPageHandler)}document.addEventListener("DOMContentLoaded",redirectToUpsellPage),window.addEventListener("mercury:load",redirectToUpsellPage);
</script>
<!-- end Redirect to Upsell Page after clicking on Add To Cart Button -->

Customize

Change the UPSELL-PAGE link 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.

Only compatible with the Simple Layout and Express Checkout in the checkout settings must be disabled for the redirect to work.


Previous
Previous

Full Width "Read More" Button

Next
Next

Frosted and Blurred Newsletter Block Button