Can you make this 'if' statement work?

Solved
John_jmk
Excursionist
22 0 5

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 %}

 

Accepted Solution (1)
JohnE10
Shopify Partner
89 10 13

This is an accepted solution.

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,

If my reply was helpful, Like and Accept. Or Buy Me a Beverage
App Development/Custom Modifications, Visit My Gig and let me how I can help
For help with your store speed optimization, Check Out My Other Gig
Feel free to email with any questions: ProjectCoder10@gmail.com

View solution in original post

Replies 7 (7)
Dan-From-Ryviu
Shopify Partner
5612 1030 1058

Hi @John_jmk 

What value did this code return? 

{{ total_price | minus: discounts_savings }}

- Helpful? Like and Accept a solution. - Donate: Buy coffee - or Paypal me ❤️
- Ryviu - Product Reviews app, collect consumer photo reviews, import reviews from AliExpress, Amazon, Etsy, Shoppe and Walmart and CSV.
- Lookfy app: Create Image Lookbook, Photo Gallery with product hotspots
- Enjoy 3 months of Shopify for $1/month. Sign up now

John_jmk
Excursionist
22 0 5

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!

Dan-From-Ryviu
Shopify Partner
5612 1030 1058

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

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

- Helpful? Like and Accept a solution. - Donate: Buy coffee - or Paypal me ❤️
- Ryviu - Product Reviews app, collect consumer photo reviews, import reviews from AliExpress, Amazon, Etsy, Shoppe and Walmart and CSV.
- Lookfy app: Create Image Lookbook, Photo Gallery with product hotspots
- Enjoy 3 months of Shopify for $1/month. Sign up now

JohnE10
Shopify Partner
89 10 13

This is an accepted solution.

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,

If my reply was helpful, Like and Accept. Or Buy Me a Beverage
App Development/Custom Modifications, Visit My Gig and let me how I can help
For help with your store speed optimization, Check Out My Other Gig
Feel free to email with any questions: ProjectCoder10@gmail.com
Asad24
Shopify Partner
180 35 31

I also recommend this 

banned
John_jmk
Excursionist
22 0 5

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

 

JohnE10
Shopify Partner
89 10 13

My pleasure. Glad it did the job for you.

If my reply was helpful, Like and Accept. Or Buy Me a Beverage
App Development/Custom Modifications, Visit My Gig and let me how I can help
For help with your store speed optimization, Check Out My Other Gig
Feel free to email with any questions: ProjectCoder10@gmail.com