- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2.3 - Display text Instead of 0 for 0 Price products
See for your reference:
https://www.manishmittal.com/
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2.3 - Display text Instead of 0 for 0 Price products
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
https://www.manishmittal.com/
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2.3 - Display text Instead of 0 for 0 Price products
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
https://www.manishmittal.com/
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2.3 - Display text Instead of 0 for 0 Price products
My Bad! Thanks for sharing, please help to check this now
https://www.manishmittal.com/
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2.3 - Display text Instead of 0 for 0 Price products
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2.3 - Display text Instead of 0 for 0 Price products
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
https://www.manishmittal.com/