how to have different number of products per row in a product grid with Craft theme

Hi

My products are of various sizes and I do not want them all to be the same size or have the same aspect ratio. My question is, how can I vary the number of products per row in a product grid. Meaning:

Row 1: 3 products of my choice

Row 2: 4 products of my choice.

So I need to vary the number per row and control which products are on which row, so similar sized products are shown on the same row.

I am using the Craft theme.

Thanks

Hi @artsy_lady ,

Please send the website link, I will check it for you

Hi @artsy_lady ,

May I suggest to update code these steps:

  1. Create a metafield for product

namespace: custom, key: width, type: decimal

  1. Go to Products → Collections → Update sort by to “Manual” → You should remove sort by featured in customize theme.

  1. Go to Products-> each product → add data for width metafield ( 33.3333 → 3 columns / row, 25 → 4 columns/row, 50 → 2 columns/ row …)

  1. Go to Store Online-> theme → edit code ->sections/main-collection-product-grid.liquid.

  2. Find “{%- for product in collection.products -%}”. Update code for li tag likes the screenshot below.

- ```

![EBOOST_4-1732690296005.png|1857x683](upload://bmUYAcMHqxqXPAEhXXeE3miEiOZ.png)

Result is the same screenshot below:

![EBOOST_3-1732690010902.png|1936x3709](upload://qiNYpTNRC8dherhhDCay8GlndbP.jpeg)

Thank you that worked perfectly! I have a follow up question. How can I make only one column per row on mobile?

Thanks!

Hi,

You only need to add code below to top of sections/main-collection-product-grid.liquid file


Thank you … worked perfectly!