Jess-7992 Posted September 8, 2020 Share Posted September 8, 2020 Hi there, I have implemented an upsell plug in – code below. Unfortunately it means that it bypasses the form that pops up when the user clicks 'add to cart'. Anyway to stop it bypassing the form? (As the form is crucial in this case!) Thanks in advance, Jess Code: <!-- Redirect to Upsell Page after clicking on Add To Cart Button --> <!-- Author: Dmitry Kiselyov @_dmitrykiselyov --> <script> // /upsell-page is the default URL. You can change it. 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"),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 --> Link to comment
IXStudio Posted September 8, 2020 Share Posted September 8, 2020 Hi, Please share your website URL. Best, Leopold Ninja Kit Extension: Upgrade your Squarespace website without coding.YouTube Preview - FREE DOWNLOAD Link to comment
Jess-7992 Posted September 8, 2020 Author Share Posted September 8, 2020 Thanks so much – I'm currently just playing with the functionality on a test site, before I add it to a client's site. You can see the test site here: ukulele-clover-lg5l.squarespace.com PW: Babboon6021 Link to comment
Jess-7992 Posted September 8, 2020 Author Share Posted September 8, 2020 FYI the code has been added to the first product on the shop page. Link to comment
tuanphan Posted September 12, 2020 Share Posted September 12, 2020 Have you tried contacting Dmitry yet? I found him to respond very quickly and always have the answer to every problem with his code. Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Olivia_Scholes Posted November 9, 2020 Share Posted November 9, 2020 @Jess-7992 Have you found a solution for this? I also need to create a redirect but the form for my products are necessary to my store. Link to comment
tuanphan Posted November 9, 2020 Share Posted November 9, 2020 1 hour ago, Olivia_Scholes said: @Jess-7992 Have you found a solution for this? I also need to create a redirect but the form for my products are necessary to my store. Dmitry updated new code in instructions.html. If you purchased Lightbox plugin, you will see. Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Jess-7992 Posted December 4, 2020 Author Share Posted December 4, 2020 Hi, sorry I just saw these replies. @tuanphan – I didn't contact Dmitry, but thanks that's a great idea. Will do in future. @Olivia_Scholes I didn't find a fix to that exact issue – as my client changed their mind and went in a different direction altogether. Sorry I can't be of help there! Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.