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.

Pennies from ^^order_total^^ in the receipt

nealsharmonnealsharmon Member
in Help edited February 2013
How can I get the order total in pennies? $10.50 becomes 1050

I need it for Optimizely tracking, which requires an integer that is in pennies.
window.optimizely = window.optimizely || [];
window.optimizely.push(['trackEvent', 'new_orabrush_revenue', ^^order_total^^]);

Anyone know how to make this calculation in twig?

This is invalid...which I got from twig documentation.
window.optimizely = window.optimizely || [];
window.optimizely.push(['trackEvent', 'new_orabrush_revenue', {{ ^^order_total^^ * 100 }}]);
  • fc_adamfc_adam FoxyCart Team

    You're very close. Try this instead:
    {{ order_total * 100 }}
  • That gave me 0
  • The dollar sign is included in order_total. How do I get it without the dollar sign?
  • fc_adamfc_adam FoxyCart Team

    Oh you're right - that is returning with the currency sign.

    I'll dig into if we have a way to get just the raw number within Twig, but for now you can achieve this with javascript:
    <script type="text/javascript">
    jQuery(document).ready(function() {
      window.optimizely = window.optimizely || [];
      window.optimizely.push(['trackEvent', 'new_orabrush_revenue', (fc_json.total_price * 100 )]);
  • Thank you. That worked.
  • lukeluke FoxyCart Team
    Thanks for bringing this up. I've been thinking about it more and more for not only Twig, but also our API in that some people need raw numbers and others need formatted strings for display and some people need both. We haven't yet landed on a solution, but we're definitely keeping it in mind.
  • Awesome. Really appreciate it Luke
Sign In or Register to comment.