I need to put the value of "Grand Total without shipping and tax" into a JavaScript on the success.phtml-page. To add the Grand Total i use the following code:
<?php echo $this->__('%s', $this->escapeHtml($this->getGrandTotal())) ?>
I was thinking about using getSubtotal instead, but that will not be correct in case of any Shopping Cart Price Rule being used. So I think the approach must be something like: "GrandTotal minus shipping minus tax"
But how can I add these parameters to the code above?
EDIT: About using getSubtotal... I would then need to know how to subtract any discount given by coupon, anyone know how to do this? I was thinking about something like this:
<?php echo $this->__('%s', Mage::getModel('checkout/cart')->getQuote()->getSubtotal() - getDiscount()); ?>
...however "getDiscount()" should be something more correct..
Thanks -Espen
You can try below code in javascript
try {
var total_ship_tax = parseFloat(parseFloat(cart.shipping_amount) + parseFloat(cart.tax_amount)).toFixed(2);
}
catch(er) {
var total_ship_tax = 0;
}
var total_amount = parseFloat(parseFloat(cart.total_amount)+total_ship_tax).toFixed(2);