“product.collections[0].next_product” is not working as no link is shown on any product page of that same collection. The collection contains 5 products.
Also, if I remove the {% if %} and {% endif %} tag, the link appears, however it appoints to current product page, not any other products.
I want to execute previous product and next product link on all my product pages. Please let me know which file should I paste the above mentioned code.
I tried this code and got the Prev Next to show on the product page within the collection. The problem is the “Next” product after 2 or 3 clicks is not the Next product and not even in the same collection. The code was added after the {% endschema %} in the main-product.liquid page. Hopefully you can figure out a way to correct - this would be so very helpful not only for my website but I suspect many users. Thank you so much. Ray
It works fine for me only if a product is part of only one collection. If same product is part of multiple collection it can show any product from those multiple collections.
Please paste this code on top of the file main-product.liquid, just below the following line of code
Position of the icon will be as shown in the top left corner of the screen , just below the header. Refer screenshot shared below.
In regards to where to insert the code, I would recommend:
firstly duplicate your theme.
Access main-product.liquid the duplicated theme
Try insert the code at different location to play with it a bit. This way you will have a better view of the structure of main-product.liquid. Indeed it’s a very large file
I pasted this code to the main-product.liquid and everything appears to be working at first. The problem is this: if a product belongs to more than one collection (which many of mine do), the “Next” click will go to a product and as you continue to hit next it is pulling products from different collections. Any suggestion on how to resolve?
In my use case, each product only belongs to 1 collection.
Just some thought here, maybe incorrect. Since {{ product.collections }} returns an array of collections. Maybe you can check if it’s possible to maintain the order of collections in that array? For example, make sure {{ product.collections[0] }} is the “target collection”