Can you help make this 'if' statement function correctly?

Hi gurus and more experienced users

I have a very simple question that you may be able to answer easily…

When I put {{ total_price | minus: discounts_savings }} in the packing slip template coding, it returns a correct value that I am after.

But I couldn’t find a way to put the above into an ‘if statement’ as below…

Any ideas?

{% if total_price | minus: discounts_savings >=35000 %}

Hi @John_jmk

What value did this code return?

{{ total_price | minus: discounts_savings }}

Hi there

It returned the total cart value before any discounts. For example,

  • Total cart value: $400

  • Discount: $40

  • Total value (final payment amount): $360

So it returned $400.

Basically, I want to make the ‘Free Gift’ text appear on the packing slip for any orders (before a discount) greater than $350. Somehow, I used other liquid variables such as subtotal_price, order_subtotal_price, etc but they didn’t seem to work thus I am trying to use these two variables in the if statement…

Hope this makes sense! Thank you!

So please try to edit your code like this and check again

{% if total_price | minus: discounts_savings >= $350 %}

Hey John,

Liquid if statements can act pretty strange at times with no rhyme or reason.

Try assigning a variable to the filter, and then use that variable inside the if statement instead.

{% assign variable = total_price | minus: discounts_savings %}

{% if variable >= 35000 %}
  your code here...
{% endif %}

It might do the trick for you.

Cheers,

I also recommend this

It worked brilliantly! Thank you so much JohnE10!!!

My pleasure. Glad it did the job for you.