magento2

Magento 2 Display minimal price without tax


Magento 2 We display product prices both with and without tax in frontend. By default minimum price and old price is rendered including tax but I have to display minimal price WITHOUT tax.

Any ideas where or how to can change this?


Solution

  • There's no perfect way to do it, best solution I have found is to override the template where the price rendering is happening and use the base amount instead of full amount for "As low as".

    My/Theme/Magento_Catalog/templates/product/price/amount/default.phtml

    <?php
    /**
     * Copyright © 2013-2017 Magento, Inc. All rights reserved.
     * See COPYING.txt for license details.
     */
    
    // @codingStandardsIgnoreFile
    
    ?>
    
    <?php /** @var \Magento\Framework\Pricing\Render\Amount $block */ ?>
    
    <?php
    if ($block->getDisplayLabel() != 'As low as') {
        $price = $block->getDisplayValue();
    }
    else {
        $price = $block->getAmount()->getBaseAmount();
    }
    ?>
    
    <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="<?php /* @escapeNotVerified */ echo $block->getPriceId() ?>"<?php endif;?>
            <?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
            data-price-amount="<?php /* @escapeNotVerified */ echo $price; ?>"
            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($price, (bool)$block->getIncludeContainer()) ?>
        </span>
        <?php if ($block->hasAdjustmentsHtml()): ?>
            <?php echo $block->getAdjustmentsHtml() ?>
        <?php endif; ?>
        <?php if ($block->getSchema()): ?>
            <meta itemprop="priceCurrency" content="<?php /* @escapeNotVerified */ echo $block->getDisplayCurrencyCode()?>" />
        <?php endif; ?>
    </span>