Skip to main content

When showing an order confirmation, is there a way to automatically have the system default to two decimal places? 

 

For example, if the total of an order is $44.80, the data comes in as $value: 44.8 (indicated by the orange arrow in image).

However in the top of preview function, it states:

John Smith

Placed Order for $44.80

(indicated by green arrow in image)

So, when I go to preview the image using this data, it doesn’t automatically format to two decimal places like US currency should and ends up leaving off the zero that should be in the second decimal place. (red arrow in image)

What I want to know is how can I have any dollar amount within an automated email that uses data from an ecommerce store to automatically format to show up to two decimal places. Meaning it will add in the zero if a number is not already provided. 

 

Additionally, I will need to know if there is a specific code to use for Shopify vs WooCommerce, as I have two different stores (and Klaviyo accounts) and need to have this feature used for both types of integrations. 

 

I’ve searched the help desk articles high and low and can’t find any information that addresses this issue. Any help or guidance is greatly appreciated!!!!

 

 

@BC_EmailMarketing

You can do this with floatformat for example {{ event|lookup:'$value'|floatformat:2 }}


Thanks! Do you know if it works for both Shopify and WooCommerce? I’ve realized how sometimes a setting will work for one and not the other. 

 


Hey @BC_EmailMarketing! The solution Bobi suggested will work on any number field, no matter where it comes from.


Thank you! @elisegaines @Bobi N. 


The snippet/code with floatformat does not work for me. I have shopify. Can someone tell me if this was changed for the new editor? Any other suggestions?


Hey @C B,

The floatformat:2 variable filter that @Bobi N. previously provided should work in both the classic and new editor.

There’s been no changes to the underlying django framework that both editors use. You can also find a glossary of some of our most commonly used filters and how to use variable filters from our Glossary of variable filters and How to use filters to customize variables Help Center articles.

David


I get the same prolem. I tried {{ event|lookup:'$value'|floatformat:2|default:'0' }} but it doesn't work. I'm using WooCommerce. By the way, I also want to add currency prefix (ex: $150.95). Can someone please help me? 


Hey @Karina,

That code you mentioned you’ve tried should work. If not, I would suggest reviewing how you’ve put the code into your email template. A common mistake many people make is incorporating some additional formatting when copy and pasting the code into the template. Another mistake I see often is using this code within a table block set to dynamic.

Additionally, to automatically include your account’s currency prefix, you can use the {% currency_format %} syntax as mentioned in our Catalog lookup tag reference Help Center article. This means you can use {% currency_format event|lookup:'$value'|floatformat:2 %} which will not only include the account’s currency prefix, but also include 2 decimal places for the price. 

David


Hello,

How can I remove the ".0" decimal if the numeric value is a whole number, so it reads "$16" instead of "$16.0"? However, if the numeric value includes decimals, like "$16.29", it should remain as is without rounding or removing the ".29" decimal.

Thank you!

 


Reply