StephP5612 Posted December 10, 2020 Posted December 10, 2020 Site URL: https://www.epicureansandiego.com/shop/epic-canvas-tote Hi y'all, I'm trying to get a redirect to an upsell page in our shop when people click "add to cart" on our products. ** Full disclosure, I am not a coder of any sorts and found the code below from SQSP Themes. When I add the code to this product, it works perfectly. When I try to add it to this product, it never actually adds the original item to the cart before redirecting to the upsell page. I'm thinking its because I have a form attached to that product at checkout for a gift message that is preventing it from working properly. I removed the code from here for the time being so I can continue to sell this item flawlessly, but I'd like to get it back up asap. Any help to work around the form would be appreciated!! Thanks so much! I used this code from SQSP Themes: <!-- 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 = "/before-you-go" //////////////////////////////// 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 -->
tuanphan Posted December 12, 2020 Posted December 12, 2020 Hi. Have you tried contacting SQSPThemes support yet? Their support is good. 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!)
StephP5612 Posted December 14, 2020 Author Posted December 14, 2020 yes, waiting to hear back! Thanks! Beyondspace 1
egrose42 Posted March 16, 2022 Posted March 16, 2022 Did you ever get a response on this? I have same issue. Code works great, but not with custom form enabled. Thanks!
tuanphan Posted March 19, 2022 Posted March 19, 2022 On 3/17/2022 at 5:48 AM, egrose42 said: Did you ever get a response on this? I have same issue. Code works great, but not with custom form enabled. Thanks! Try contacting Plugin Author first 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!)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment