Wednesday 20 June 2018

Solutions of facing problems while fatching IDs in Shopify - Liquid

Hello,
blog on shopify liquid code,

use of "{{forloop.index}}" ,

input : 
{% for product in collections.frontpage.products %}
    {{ forloop.index }}
{% else %}
    // no products in your frontpage collection
{% endfor %}
  
 output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

  • if you are facing problems while assigning IDs and names of  "<divs>" or anchor tags at the time of placing tabify or accordion , you should use id = {{forloop.index}} in your cart or product loops . 
  • Dont assign {{product.id}} or {{block.id}} as an IDs of  "<div> / <a>" , it is very hard to get those things when you started applying your Custom jQuery or start making / adding own functionalities. it would be easy when you have used {{forloop.index}}, As it is going to be easy to target and fetch in jquery

Infinite scroll on collection page in Shopify

 Hello, Collection page structure is as followed {% paginate collection.products by 48 %} <div class="collection-content"> ...