The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

order_total without currency symbol in Twig receipt template

sblombergsblomberg Member
in Help edited January 2014
Hey FoxyCart support,

I would like to be able to access the order total in my receipt template without the currency symbol. I found this forum post from last year that lists a Javascript solution, but that unfortunately doesn't help me as I need the variable at page run time.

The reason JS doesn't work is that I'm loading an affiliate script with a <script> element. Here's the script integration instructions I'm attempting to implement. Here's what my script looks like thus far:
<script id="_sspx2" 
data-amount="{{ order_total }}" 
data-email="{{ email }}" 
data-pub="{{ sspx }}" 

Everything's working except the data-amount, as that attribute requires order total without the currency symbol. {{ order_total }} doesn't work because it includes the dollar sign as well.

I've attempted using the Twig slice function to return everything except the first character like so:
{{ order_total[1:] }}

However, doing so doesn't let me save my receipt template, as it returns this error: Filter "slice" is not allowed

Any other Twig variables/filters/functions I can use to get the order total without currency symbol?

  • fc_adamfc_adam FoxyCart Team

    Good question. In an upcoming version we'll default all currency values to their raw amount without any formatting with currency symbols etc - but for now you need to use the 'replace' twig function:
  • Thanks much Adam - I was able to use the Twig 'replace' filter as recommended to remove the dollar sign and thousands comma from the order_total. Here's the code I used for anyone else who may find it useful:

    {% set my_total = order_total|replace({'$': '', ',': ''}) %}

    Once the variable is set, it's accessed like so in the FoxyCart template:

    {{ my_total }}
Sign In or Register to comment.