Pricing Conditions Not Working Properly

Background: We have multiple pricing structures on our website as some of our vendors have a minimum advertised price (MAP) and we can’t show the lower sell price unless the shopper adds it to their cart.

For product emails, I’m trying to make it so if a MAP value(eyemagine_advertised_price) is defined, it should output that price, and if it’s not, to default to unit price. I originally tried the below code, which worked.

 {% if item2.crmobject_field.properties.eyemagine_advertised_price is defined %}
 <span style="color: #000000;">{{ item2.crmobject_field.properties.eyemagine_advertised_price|format_currency("en-US", "USD") }}</span>
 {% else %}
 <span style="color: #000000;">{{ item2.crmobject_field.properties.price|format_currency("en-US", "USD") }}</span>
 {% endif %}

However, some of our products seem to have a MAP value of $0, and I want to make sure that doesn’t show up. I updated to include MAP needs to be defined and does not equal $0.00:

 {% if item2.crmobject_field.properties.eyemagine_advertised_price is defined and item2.crmobject_field.properties.eyemagine_advertised_price != '$0.00' %}
 <span style="color: #000000;">{{ item2.crmobject_field.properties.eyemagine_advertised_price|format_currency("en-US", "USD") }}</span>
 {% else %}
 <span style="color: #000000;">{{ item2.crmobject_field.properties.price|format_currency("en-US", "USD") }}</span>
 {% endif %}

It broke the code and will now only show the unit price.

Is there a simple fix for this or will I have to have my ecommerce integration partner update our sync settings to exclude anything that shows as $0?

Hey, @IGardner :waving_hand: Thanks for your question. Hopefully, someone smarter than me will come along and give us the magic answer. But meanwhile, have you tried something like this?

{% if item2.crmobject_field.properties.eyemagine_advertised_price is defined and item2.crmobject_field.properties.eyemagine_advertised_price > 0 %}
 <span style="color: #000000;">{{ item2.crmobject_field.properties.eyemagine_advertised_price|format_currency("en-US", "USD") }}</span>
{% else %}
 <span style="color: #000000;">{{ item2.crmobject_field.properties.price|format_currency("en-US", "USD") }}</span>
{% endif %}

This version checks if eyemagine_advertised_price is defined and greater than 0 without comparing it to a string representation of a currency value.

Best,

Jaycee

Oh my gosh, yes thank you! We only have one developer who has a lot of projects on his hands right now so I’m doing my best to put my limited coding knowledge to use :sweat_smile:

Hey, @IGardner :waving_hand: You’re doing great! I’m glad we could teamwork it and get you moving forward. Have fun building! — Jaycee