cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 Product Page Inc Tax Excl Tax - Ordering

Magento 2 Product Page Inc Tax Excl Tax - Ordering

Hi All

I have my products set to display both Price Excl Tax and Incl Tax - set in admin/stores/configuration/sales/tax - Price Display Settings

Both prices display on the product page but only the Excl. Tax label displays.
I also wanted the Excl. Tax price to display above the Incl. Tax price.
I used the following code suggested elsewhere on this forum.

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

<?php /** @var $block \Magento\Framework\Pricing\Render\Amount */ ?>

<span class="price-container <?= $block->escapeHtmlAttr($block->getAdjustmentCssClasses()) ?>"
        <?= $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
    <?php if ($block->getDisplayLabel()) :?>
        <span class="price-label"><?= $block->escapeHtml($block->getDisplayLabel()) ?></span>
    <?php endif; ?>
    <?php if ($block->hasAdjustmentsHtml()): ?>
    <?= $block->getAdjustmentsHtml() ?>
    <?php endif; ?>
    <span <?php if ($block->getPriceId()) :?> id="<?= $block->escapeHtmlAttr($block->getPriceId()) ?>"<?php endif;?>
        <?= ($block->getPriceDisplayLabel()) ? 'data-label="' . $block->escapeHtmlAttr($block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes()) . '"' : '' ?>
        data-price-amount="<?= $block->escapeHtmlAttr($block->getDisplayValue()) ?>"
        data-price-type="<?= $block->escapeHtmlAttr($block->getPriceType()) ?>"
        class="price-wrapper <?= $block->escapeHtmlAttr($block->getPriceWrapperCss()) ?>"
    ><?= $block->escapeHtml($block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()), ['span']) ?></span>
    <?php if ($block->hasAdjustmentsHtml()) :?>
        <?= $block->getAdjustmentsHtml() ?>
    <?php endif; ?>
    <?php if ($block->getSchema()) :?>
        <meta itemprop="price" content="<?= $block->escapeHtmlAttr($block->getDisplayValue()) ?>" />
        <meta itemprop="priceCurrency" content="<?= $block->escapeHtmlAttr($block->getDisplayCurrencyCode()) ?>" />
    <?php endif; ?>
</span>

But I'm getting the following:

tx.JPG

If I remove the second occurrence of this code:

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

I see the correct pricing and they display in the correct order - But, the labels (Excl, Incl) don't display.

Can anyone advise please?

Many Thanks in Advance

Andy

1 REPLY 1

Re: Magento 2 Product Page Inc Tax Excl Tax - Ordering

Hello Andy,

We have the same problem, the text Excl. Tax: is not displayed after we changed the default.phtml. Did you already have a solution?

Thank you in advance

 

Kind regards

Marco