cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.3 - Display text Instead of 0 for 0 Price products

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

See for your reference:

 

Screenshot 2020-06-03 at 5.05.33 PM.pngScreenshot 2020-06-03 at 5.05.54 PM.png

Manish Mittal
https://www.manishmittal.com/

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

Any help? where i need to paste the code? I ma using magento 2.3.3 with the default luma theme.

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

@Aveeva 

 

I have just posted an article in my blog for this, you can follow the same:

 

https://www.manishmittal.com/how-to-display-free-for-product-with-0-00-price-in-magento-2/

 

Let me know if you need any other help. Thanks

Manish Mittal
https://www.manishmittal.com/

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

My code :

 

 

<?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; ?>
    <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> -->

<?php if ($block->getDisplayValue() != 0 ) {  ?>

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

 

 

After i did  

 

php bin/magento setup:static-content:deploy -f

php bin/magento cache:flush

 

Free text not applied, anything else i forget? Thanks.

 

 

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

@Aveeva 

 

Not sure in which file you have modified, I have shared an good article with you to follow using plugin. Please try this.

 

Or for now if you want to test with direct change in core that also you can try it will work

Manish Mittal
https://www.manishmittal.com/

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

@Manish Mittal  Is it right path,

app/code/MM/Training/etc/frontend/di.xml

                     (different path)

app/code/SR/MagentoCommunity/Plugin/Pricing/Render/PriceBox.php

in your module.

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

@Aveeva 

 

My Bad! Thanks for sharing, please help to check this now

Manish Mittal
https://www.manishmittal.com/

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

@Aveeva 

 

Let me know if this will work for you!

Manish Mittal
https://www.manishmittal.com/

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

@Manish Mittal  No, anything else i forget to add,

 

di.xml => https://snipboard.io/VOs0Ny.jpg

 

PriceBox.php => https://snipboard.io/InsWo7.jpg

Re: Magento 2.3 - Display text Instead of 0 for 0 Price products

@Aveeva 

 

Is this module enabled? cause I tried this is perfectly working fine. 

 

Try to run 

php bin/magento setup:upgrade

php bin/magento c:f

 

It should work

Manish Mittal
https://www.manishmittal.com/