totals是指购买订单信息下面的一个汇总价格信息,一般有小计、扣折、运费、税率等价格信息。通常情况下按系统的就可以,但无奈magento2这个顺序不合理,这个问题在magento2.1仍然存在,所以只能自己手动改。

app/design/frontend/Forever/theme/Magento_Sales/templates/email/totals.phtml

<?php
$totals = $block->getTotals();
uksort($totals, function($a, $b){
    $map = [
        'subtotal' => 1,
        'shipping' => 2,
        'fee' => 3,
        'discount' => 4,
        'tax' => 5,
        'grand_total' => 6
    ];
    if($map[$a] == $map[$b]) return 0;
    return $map[$a] > $map[$b] ? 1 : -1;
});
?>
<?php foreach ($totals as $_code => $_total):?>
    <?php if ($_total->getBlockName()): ?>
        <?php echo $block->getChildHtml($_total->getBlockName(), false); ?>
    <?php else:?>
        <tr class="<?php /* @escapeNotVerified */ echo $_code?>">
            <th style="background-color:#ffffff;font-size:12px;" <?php /* @escapeNotVerified */ echo $block->getLabelProperties()?> scope="row">
                <?php if ($_total->getStrong()):?>
                    <strong><?php if($_total->getLabel() == 'Estimated Total'){ echo __('Total'); }else{ echo $block->escapeHtml($_total->getLabel()); } ?></strong>
                <?php else:?>
                    <?php echo $block->escapeHtml($_total->getLabel());?>
                <?php endif?>
            </th>
            <td style="background-color:#ffffff;font-size:12px;" <?php /* @escapeNotVerified */ echo $block->getValueProperties()?> data-th="<?php if($_total->getLabel() == 'Estimated Total'){ echo __('Total'); }else{ 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?>
            </td>
        </tr>
    <?php endif?>
<?php endforeach?>

猫之良品
2.5k 声望139 粉丝

资深Drupal, magento与Joomla


引用和评论

0 条评论