Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search

FaellesGro

Member
  • Posts

    2
  • Joined

  • Last visited

  1. 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. 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...