Skip to content

How can I get price excluding tax #35763

@FilipS02

Description

@FilipS02

Hi, I want to display price excluding tax.
In vendor/magento/module-sales/view/frontend/templates/email/items.phtml I added new th.
items.phtml with my custom th:
`<?php
/**

  • Copyright © Magento, Inc. All rights reserved.
  • See COPYING.txt for license details.
    /
    // phpcs:disable Magento2.Templates.ThisInTemplate
    /
    * @var $block \Magento\Sales\Block\Order\Email\Items */
    ?>
getOrder() ?>
<?php $_items = $_order->getAllItems(); ?>
<table class="email-items">
    <thead>
        <tr>
            <th class="item-info">
                <?= $block->escapeHtml(__('Items')) ?>
            </th>
            <th class="item-qty">
                <?= $block->escapeHtml(__('Qty')) ?>
            </th>

            /*MY CUSTOM TH*/
            <th class="item-price">
                <?= $block->escapeHtml(__('Price excluding tax')) ?>
            </th>
            /*END OF MY CUSTOM TH*/

            <th class="item-price">
                <?= $block->escapeHtml(__('Price')) ?>
            </th>
        </tr>
    </thead>
    <?php foreach ($_items as $_item) : ?>
        <?php if (!$_item->getParentItem()) : ?>
            <tbody>
                <?= $block->getItemHtml($_item) ?>
            </tbody>
        <?php endif; ?>
    <?php endforeach; ?>
    <tfoot class="order-totals">
        <?= $block->getChildHtml('order_totals') ?>
    </tfoot>
</table>`

In vendor/magento/module-sales/view/frontend/templates/order/items/renderer/default.phtml I added this code
`
prepareSku($block->getSku()) ?>

/* MY CUSTOM TD */
<td class="col price" data-th="<?= $block->escapeHtml(__('Price excluding tax')) ?>">
    <?= $block->???????() ?>
</td>
/* END OF MY CUSTOM TD */

<td class="col price" data-th="<?= $block->escapeHtml(__('Price')) ?>">
    <?= $block->getItemPriceHtml() ?>
</td>`

Which variable I should use instead of "???????" to display price without tax ?

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions