I don't understand this handle, can you explain it to me?

Solved
New Member
1 0 0
In my product.liquid there's this:
 
<div class="something" >
{%- if linklists[product.handle].links.size == 0 -%}
...
{%- endif -%}
</div>
 
I don't understand linklists[product.handle].links.size does and the document is very scared. Can you explain what the purpose of this statement is?
 
0 Likes

Success.

Shopify Expert
2648 60 643

Handle is a unique (among the same type) identifier for shop data, like products, collections, link lists (menus).

The code checks if there is no menu with the same handle as current product has, or if this menu has no links added. Then it does something.

 

Say, you have a product called "Snowboard" (with handle most probably being snowboard) and menu called the same, Snowboard, they will have the same handle... If this menu is empty, your code will do something, but if this menu has links added, it will not. 

 

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
0 Likes