Ecommerce Shopify WordPress Discussion

Why if statement in Shopify-Liquid is not working as expected?

I'm working with array of array in shopify-liquid and when i am trying to use the if statement to get only records where charge[2] > 0 but somehow its including the records where charge[2] = 0 and i'm not able to understand why is it happening. {% assign array_of_arrays = [["0.0","5.0","0.0"],["0.0","6.6","8.8"],["0.0","9.9","1.1"]] %} {%- for header in array_of_arrays -%} {%- for charge in header[-1] -%} {% if charge[2] > 0 %} "this is it!!" {% endif%} {%- endfor -%} {%- endfor -%} Can anyone please help me understand where i'm making the mistake?
I found a way to get this sorted by using a small trick. Before, if sattement i convereted the string to a float and hence it worked. {%- for header in array_of_arrays -%} {%- for charge in header[-1] -%} {%- assign char_2 = charge[2] | replace: ',' '.' | string.to_float -%} {% if char_2 > 0 %} charge: {{}} {{charge}} {{}} {% endif%} {%- endfor -%} {%- endfor -%} I hope it helps.

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.