Hi guys!
I hope you’re all doing well. I have a customization query and would greatly appreciate your insights.
Here’s the scenario I’m dealing with:
Main products: Roses (Red, Fucsia, Pink, and Pale red)
Related products: Chocolates and drinks
I want to achieve the following:
If a Main product (e.g., Fucsia) has not been added to the cart, attempting to add a Related product (e.g., Chocolates) to cart should display a message box saying, “Cannot add this to the cart because a Main product is not in the cart.”
I’ve tried implementing a solution with the following JavaScript code:
I’d love to hear your thoughts on this approach and if there’s a more efficient way to handle this scenario. Your help is much appreciated!
Thank you in advance.
Show your work not just stand alone code.
https://community.shopify.com/c/blog/how-to-get-support-from-the-community/ba-p/2254458
Getting this behavior will vary wildly among themes and that code reads like psuedo code such as presumes the theme puts cart information into local storage which most themes don’t bother to do , and there’s no creation for agregarBtn variable that correlates to all other buttons.
But if it’s working it’s fine move on.
If it’s not working you need this customization built then contact me by my email for services.
Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.
Hi Paul,
Thank you for your prompt response. I appreciate your feedback on the code provided. The example code is not functional, and I understand your point about variations among themes.
To provide more context, here are the details:
- Store URL: https://6a827c.myshopify.com/
- Theme: Studio
- The Related Products can only be accessed in Main product pages (Fucsia, Pink Roses, Red Roses and Pale Red Roses).
I would appreciate any further guidance or customization you can offer to make the code work seamlessly with my specific theme. If you are available for such services, I’d like to discuss the details further. I’ll reach you at the email provided in your signature.
Thank you for your assistance, and I look forward to resolving this issue.
Best regards,