Better display of cart amount breakdown

master
Mark Moffat 2020-01-03 22:59:00 +10:30
parent 706bce7b20
commit f96d8335d6
3 changed files with 17 additions and 1 deletions

12
app.js
View File

@ -290,6 +290,18 @@ handlebars = handlebars.create({
return value.replace(/^\w/, (chr) => {
return chr.toUpperCase();
});
},
math: (lvalue, operator, rvalue, options) => {
lvalue = parseFloat(lvalue);
rvalue = parseFloat(rvalue);
return{
'+': lvalue + rvalue,
'-': lvalue - rvalue,
'*': lvalue * rvalue,
'/': lvalue / rvalue,
'%': lvalue % rvalue
}[operator];
}
}
});

View File

@ -170,5 +170,7 @@
"Return to information": "Return to information",
"Search shop": "Search shop",
"Dashboard": "Dashboard",
"Create order": "Create order"
"Create order": "Create order",
"Order shipping amount": "Order shipping amount",
"Order net amount": "Order net amount"
}

View File

@ -31,6 +31,8 @@
{{#if result.orderPaymentMessage}}
<li class="list-group-item"><strong> {{ @root.__ "Payment Message" }}: </strong><span class="float-right">{{result.orderPaymentMessage}}</span></li>
{{/if}}
<li class="list-group-item"><strong> {{ @root.__ "Order net amount" }}: </strong><span class="float-right">{{currencySymbol config.currencySymbol}}{{formatAmount (math result.orderTotal '-' result.orderShipping)}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "Order shipping amount" }}: </strong><span class="float-right">{{currencySymbol config.currencySymbol}}{{formatAmount result.orderShipping}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "Order total amount" }}: </strong><span class="float-right">{{currencySymbol config.currencySymbol}}{{formatAmount result.orderTotal}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "Email address" }}: </strong><span class="float-right">{{result.orderEmail}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "First name" }}: </strong><span class="float-right">{{result.orderFirstname}}</span></li>