Jump to content

FaellesGro

Member
  • Posts

    2
  • Joined

  • Last visited

Reputation Activity

  1. Like
    FaellesGro got a reaction from Beyondspace in Referring to two different upsell pages, depending on the specific product   
    Thanks for your answers, guys. 
    @bangank36 - I actually tried that before, but now found out the I had to disable Ajax Loading for it to work 🙂 
    Best, 
    Ida
  2. Like
    FaellesGro reacted to Beyondspace in Referring to two different upsell pages, depending on the specific product   
    On product Additional Info you can add the code block, make it redirect to different upsell page per product
  3. Like
    FaellesGro got a reaction from Beyondspace in Referring to two different upsell pages, depending on the specific product   
    Site URL: https://www.faellesgro.dk/vlg-bydel
    Hi there, 
    I have been working on this for a while now. I have created a page with summary blocks referring to our membership products (see URL), and would now like to redirect customers to two different upselling pages - '/tilkoeb-1' & '/tilkoeb-2', depending on which product, they choose. 
    I have used this code to redirect to an upsell page, when customers click Add To Cart: 
    <!-- Redirect to the Upsell Page after clicking on the Add To Cart button -->
    <!-- Author: Dmitry Kiselyov @_dmitrykiselyov -->
    <script>
    function redirectToUpsellPage() {
      var upsellPageUrl = '/tilkoeb-1';
      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 -->
    Everything is working fine, when I go in through the specific product URL, as I've split the products on two different product pages and added the code to these pages. But when I go in through the page with the summary blocks, the code isn't working.
    Is it possible to add the code directly to the specific products - and how? 
    Or can the code be rewritten to refer to specific products/product pages? 
    I hope someone here can help me?? 
    Kind regards,
    Ida 
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.