Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hey,
i have a issue with the Product Form -> add to Cart.
i added a "buy together" feature in my store, this feature works and add only the selected products to cart.
Now i have the issue that if this peace of code is under the variant selector from the main product, it will add the last item from the feature to cart.
When i move it over the selector it works fine. Now i was thinking he select the wrong item because of the form request, but i have logged the event "add to cart" and in this event is the right variant and before the request is send is still the right product. I dont understand whats happen in the background to change the variation, is this a bug or do i need to create my own request like in my feature?
This feature is actually only in one product active
https://store8.de/products/galaxy-guardian?variant=44306802999593
King Regards
Jamie
Your code seems to be very neat and clear, so as per my understanding movement of code block should not affect the working. Can you share a URL where I can check the same?
Hey @gr_trading ,
sure here are two products, one before the main selection and one after:
before:
https://store8.de/products/galaxy-guardian
after:
https://store8.de/products/reliefer-2-0
The events are also in the console.
Thank you
it's working fine on my end.
This works without issues, you need to buy the main product and then you will see. He takes the last one of the feature when the form is after the main product selection.
Put your frequently-bought-together section after closing the product form tag.
You are right, there are multiple solutions, i can implement my own add to cart action and prevent this usecase, but i need to understand what happens because the right product is in the request. Something in the /add/cart endpoint must happen, a recheck or something like that. Like i said before, i was thinking the same, he get the wrong product because it is in the form, but he takes the right one and this is my problem what i dont understand.
I have found the issue, sometimes we should look on all variables, in the request is the whole form sended and your "add-to-cart" route is taken the last selected product. Maybe here should be something integrated and look if its the main product or something else. I have change the request and send only the "currentVariant" and not the whole form.
Anyway its resolved, but maybe some of your devs can look over this route and prevent something like this.
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025