we have changed our site to display prices in 4 decimal places using this extension

However on the new order email we would like to trim off the extra zeros. This is how it is displaying...

Subtotal £15.2500

Shipping & Handling £7.5000

Tax £4.5500

Grand Total £27.3000

I think these are being added to the email via this


<?php foreach ($block->getTotals() as $_code => $_total): ?>
<?php if ($_total->getBlockName()): ?>
    <?php echo $block->getChildHtml($_total->getBlockName(), false); ?>
<?php else:?>
<tr class="<?php /* @escapeNotVerified */ echo $_code?>">
    <th <?php /* @escapeNotVerified */ echo $block->getLabelProperties()?> scope="row">
        <?php if ($_total->getStrong()):?>
        <strong><?php echo $block->escapeHtml($_total->getLabel());?></strong>
        <?php else:?>
        <?php echo $block->escapeHtml($_total->getLabel());?>
        <?php endif?>
    <td <?php /* @escapeNotVerified */ echo $block->getValueProperties()?> data-th="<?php echo $block->escapeHtml($_total->getLabel());?>">
        <?php if ($_total->getStrong()):?>
        <strong><?php /* @escapeNotVerified */ echo $block->formatValue($_total) ?></strong>
        <?php else:?>
        <?php /* @escapeNotVerified */ echo $block->formatValue($_total) ?>
        <?php endif?>
<?php endif?>

Which is controlled (I think) by this...


Can we format the totals here?


  • yes, you can but first override file. – Anas Mansuri Jun 13 '19 at 13:37
  • which one? and how to format it? thanks – Richard Laws Jun 13 '19 at 14:04
  • toDecimal() - try with this function – Anas Mansuri Jun 14 '19 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.