1

So I wanted to change the layout of my invoice emails, especially order totals. I wanted labels to align right. I copied my totals.phtml file in my theme and added my styling.

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * @var $block \Magento\Sales\Block\Order\Totals
 * @see \Magento\Sales\Block\Order\Totals
 */
?>
<?php foreach ($block->getTotals() as $_code => $_total) : ?>
    <?php if ($_total->getBlockName()) : ?>
        <?= $block->getChildHtml($_total->getBlockName(), false) ?>
    <?php else :?>
        <tr class="<?= $block->escapeHtmlAttr($_code) ?>">
            <th <?= /* @noEscape */ $block->getLabelProperties() ?> scope="row" style="text-align: right !important; padding-right:20px">
                <?php if ($_total->getStrong()) : ?>
                    <strong><?= $block->escapeHtml($_total->getLabel()) ?></strong>
                <?php else : ?>
                    <?= $block->escapeHtml($_total->getLabel()) ?>
                <?php endif ?>
            </th>
            <td <?= /* @noEscape */ $block->getValueProperties() ?> data-th="<?= $block->escapeHtmlAttr($_total->getLabel()) ?>">
                <?php if ($_total->getStrong()) : ?>
                    <strong><?= /* @noEscape */ $block->formatValue($_total) ?></strong>
                <?php else : ?>
                    <?= /* @noEscape */ $block->formatValue($_total) ?>
                <?php endif?>
            </td>
        </tr>
    <?php endif; ?>
<?php endforeach?>

It gave the desired stying changes except for TAX row in my order totals. enter image description here

for Tax row I did some research and I found tax module in vendor so I copied tax.phtml from tax module tried making changes. But still the TAX label is there in the center. Can anyone tell me how can I change the alignment of tax field.

1
  • Did you find a solution to this tax label alignment issue?
    – Tobe_Sta
    Commented Feb 22, 2023 at 4:23

1 Answer 1

0

You can disable tax calculation for orders in the backend config https://www.mageplaza.com/kb/how-to-configure-us-tax-magento-2.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.