Using Liquid to Create a New Table Row Each Time a New Product is Added

Using Liquid to Create a New Table Row Each Time a New Product is Added

corroadesigns
Visitor
1 0 0

Hi there,

 

I have a client would will have over 800+ products and would like to have table in their collection pages like Uline.com or this image here:

 

Screen Shot 2019-11-19 at 5.44.08 PM.png

I would like to have rows be automagically created each time a new product is added to the collection. The actual data within the rows shouldn't be an issue, but I'm not 100% sure about the rows.

 

I've created smaller if else statements that had a limit, but I'm hoping to create some sort of a loop so we can create a few lines of code for one row once instead of manually adding more code each time we add a new product.

 

Any advice is appreciated. Thanks so much in advance!

Replies 4 (4)

leinaD
Shopify Partner
47 1 7

Hi corroadesigns,

 

if you want to list all products of your collection on your page, use this:

 

<table>
<tr>
{% for product in collection.products %} <td>{{ product.title }}</td>
<td>...</td>
{% endfor %}
</tr>

</table>

 

Regards,

Daniel

adventmedia
Pathfinder
128 0 31

Where do you add this code?

leinaD
Shopify Partner
47 1 7

@adventmedia 

Add this code in the template 'collection.liquid'. This way it appears on your collection page. 

ERVP
Visitor
2 0 0

Did you ever get this working?  I need the exact same thing, Uline has the closest version of what I need.