Passing order.total_price into a certain format

Highlighted
New Member
2 0 0

Hello,

We're in the middle of working with a post-order referral service, and part of the process is implementing a script to pass on order values to confirm a sale.

They require the format of '###.##' but {{ order.total_price }} only exports as a continuous number e.g. 2250 instead of 22.50.

Is there any way to alter the formatting once the data is pulled for this type of instance?

Full script code here:

<!-- Rakuten Marketing Additional Conversion Fields -->
<script type="text/javascript">
{%- if customer.has_account and customer.orders.size > 1 -%}
    {%- assign rakutenMarketing_customerStatus = 'Existing' -%}
{%- elsif customer.has_account and customer.orders.size <= 1 -%}
    {%- assign rakutenMarketing_customerStatus = 'New' -%}
{%- else -%}
    {%- assign rakutenMarketing_customerStatus = 'Guest' -%}
{%- endif -%}
    window.rm_Shopify = {
        customerStatus: '{{ rakutenMarketing_customerStatus }}',
        orderName: '{{ order_number }}'
    };
</script>
<!-- End Rakuten Marketing Additional Conversion Fields-->

<script>
/*** Do not change ***/
var SORETO = {};
SORETO.Client = {};
SORETO.User = {};
SORETO.Order = {};
/*** Set your transaction parameters ***/
SORETO.Client.id = '___________';
SORETO.User.firstName = '{{ customer.first_name }}';
SORETO.User.email = '{{ order.email }}';
SORETO.Order.id = '{{ order.order_number }}';
SORETO.Order.total = '{{ order.total_price }}';
/*** Do not change ***/
(function(d, s, id) {
var script, first_script = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
script = d.createElement(s);
script.id = id;
script.src="https://api.soreto.com/scripts/" + id + ".min.js";
first_script.parentNode.insertBefore(script, first_script);
}(document, 'script', 'soreto'));
</script>

and the company who we are trying to on-board with using this service can be found here: https://www.soreto.com/

Many thanks,
Danny


0 Likes
Shopify Expert
2686 67 683

The easiest would most probably be to use

SORETO.Order.total = '{{ order.total_price | divided_by: 100.0 }}';

https://help.shopify.com/themes/liquid/filters/math-filters 

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
I am away till Feb-15.
0 Likes
Highlighted
New Member
2 0 0

I was able to solve it by doing this:

SORETO.Order.total = '{{ order.total_price | money_without_currency }}';
0 Likes