Magento – Changing The Order Price “Inc. Tax” and “Excl. Tax” is displayed

magento-2.1pricetax

I am trying to change the way prices are displayed on the product page and category pages.

If

Configuration -> Sales -> Tax -> Price Display Settings -> Display
Product Prices In Catalog —> "Including and Excluding Tax"

Magento by default display prices

$66

Excl. Tax: $60

Magento 2 Product Page Price Inc. Tax and Excl. Tax

I would like to display prices as

$60 Excl. Tax

$66 Inc. Tax

I have moved default.phtml to my child theme

/app/design/frontend/mytheme/mytheme/Magento_Catalog/templates/product/price/amount/default.phtml

But now I have no idea what needs to be done.

<span class="price-container <?php /* @escapeNotVerified */ echo $block->getAdjustmentCssClasses() ?>"
    <?php echo $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
    <span class="price-label"><?php /* @escapeNotVerified */ echo $block->getDisplayLabel(); ?></span>
<?php endif; ?>
<span <?php if ($block->getPriceId() && $id!=''): ?> id="<?php echo $id ?><?php /* @escapeNotVerified */ echo $block->getPriceId() ?>"<?php endif;?>
    <?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
    data-price-amount="<?php /* @escapeNotVerified */ echo $block->getDisplayValue(); ?>"
    data-price-type="<?php /* @escapeNotVerified */ echo $block->getPriceType(); ?>"
    class="price-wrapper <?php /* @escapeNotVerified */ echo $block->getPriceWrapperCss(); ?>"
    <?php echo $block->getSchema() ? ' itemprop="price"' : '' ?>>
    <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
</span>

Best Answer

<?php if ($block->hasAdjustmentsHtml()): ?>
    <?= $block->getAdjustmentsHtml() ?>
<?php endif; ?>

Add this code before this block of code

<span <?php if ($block->getPriceId()): ?> id="<?= /* @escapeNotVerified */ $block->getPriceId() ?>"<?php endif;?>
    <?= ($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
    data-price-amount="<?= /* @escapeNotVerified */ $block->getDisplayValue() ?>"
    data-price-type="<?= /* @escapeNotVerified */ $block->getPriceType() ?>"
    class="price-wrapper <?= /* @escapeNotVerified */ $block->getPriceWrapperCss() ?>">
    <?= /* @escapeNotVerified */ $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
</span>

Take a look at Snapshot

Related Topic