CMS Development

IGardner
Participant

Pricing Conditions Not Working Properly

SOLVE

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?

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

Pricing Conditions Not Working Properly

SOLVE

Hey, @IGardner 👋 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


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !

View solution in original post

0 Upvotes
3 Replies 3
Jaycee_Lewis
Solution
Community Manager
Community Manager

Pricing Conditions Not Working Properly

SOLVE

Hey, @IGardner 👋 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


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes
IGardner
Participant

Pricing Conditions Not Working Properly

SOLVE

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 😅

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Pricing Conditions Not Working Properly

SOLVE

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


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes