All things Shopify and commerce
I'm trying to implement a specific condition if the number of blocks are only 1 and if number of blocks are 2 in for loop and if number of blocks are 3 and the last condition will be if number of blocks are 4 or greater than 4
What could be the possible condition here?
{%for block in section.blocks%}
//if there is only one block {
do this
}
//if there are two blocks {
do this
}
//if there are three blocks {
do this
}
//if there are four blocks or greater than 4 {
do this
}
{%endfor%}
Solved! Go to the solution
This is an accepted solution.
Hi @Ali_Zeeshan
try it
{%- case section.blocks.size -%}
{% when 1 %}
// code here
{% when 2%}
{% when 3%}
{% else %}
{%- endcase -%}
This is an accepted solution.
It worked like a cheery🍒 thanks
This is an accepted solution.
Hi @Ali_Zeeshan
try it
{%- case section.blocks.size -%}
{% when 1 %}
// code here
{% when 2%}
{% when 3%}
{% else %}
{%- endcase -%}
This is an accepted solution.
It worked like a cheery🍒 thanks
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024