在 opencart(2.0.3.1) 订单电子邮件(客户和管理员)上为运费加税

Add Tax to shipping cost on opencart(2.0.3.1) order email (client and admin)

如果文本手续费存在,我想添加手续费订单的运输重量成本。我也想避免编辑任何控制器。我如何通过从我的视图中编辑 confirm.tpl 来做到这一点?

<tfoot>
      <?php foreach ($totals as $total) { ?>
      <tr>
        <td colspan="4" class="text-right"><strong><?php echo $total['title']; ?>:</strong></td>
        <td class="text-right"><?php echo $total['text']; ?></td>
      </tr>
      <?php } ?>
</tfoot>

这是我到目前为止所做的:

<tfoot>
      <?php foreach ($totals as $total) { ?>

      <?php 
        if(strpos($total['title'], "Handling") !== false) {
          // handling exists, what now?
        }
      ?>
      <tr>
        <td colspan="4" class="text-right"><strong><?php echo $total['title']; ?>:</strong></td>
        <td class="text-right"><?php echo $total['text']; ?></td>
      </tr>
      <?php } ?>
</tfoot>
<?php

$totals = array(
    array('title' => 'Handling Fee', 'text' => '₱171.33'),
    array('title' => 'Sub-Total', 'text' => '₱17,132.85'),
    array('title' => 'Nationwide Fee', 'text' => '₱280.00')
);


?>


<tfoot>
    <?php $toAdd = 0; foreach ($totals as $total) { ?>
    <?php 
    if(strpos($total['title'], "Handling") !== false) { 
        $toAdd = (float)preg_replace('/[^.a-zA-Z0-9]/s', '', $total['text']);
    } else { ?> 
        <tr>
            <td colspan="4" class="text-right"><strong><?php echo $total['title']; ?>:</strong></td>
            <td class="text-right"><?php 
                if($toAdd && (strpos($total['title'], 'Nationwide') !== false)) {
                    $nationwide = (float)preg_replace('/[^.a-zA-Z0-9]/s', '', $total['text']);
                    echo "₱". number_format($nationwide + $toAdd, 2, '.', ','); 
                } else {
                    echo $total['text']; 
                }
            ?></td>
        </tr>
    <?php } ?>
    <?php } ?>
</tfoot>

这是一个干巴巴的答案。如果我可以改善这一点,请让我现在。它使用 strpos 来隐藏手续费,并 preg_replace 转换为 float 以便我执行一些基本的算术运算。