0

I'm facing a weird issue with the product detail page on magento 2.4.3. The product price will be shown while loading the page and changed to 0.000 once the page is loaded completely. The price is correct on the product listing page. Also tried to upgrade the magento version from 2.4.3 to 2.4.3-p1, but still facing the issue.

Thanks,

Attaching the screenshots. enter image description here enter image description here

1
  • a client of mine had this error with this module of Bss Simpledetailconfigurable
    – nhungo duc
    Nov 22 '21 at 9:50
0

Please Try below solution to fix it:

You need to replace the code of vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml with below code:

<?php /** @var $block \Magento\Framework\Pricing\Render\Amount */ ?>
<?php
$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$storeId = $storeManager->getStore()->getStoreId();
?>
<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()) ?>"
        <?= $storeId == 2 ? "style=display:none;" : ''; // here i got this issue in specific store view so i have done it for that store only ?>
    ><?= $block->escapeHtml($block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()), ['span']) ?></span>
    <?php if($storeId == 2): ?> <?= // here i got this issue in specific store view so i have done it for that store only ?>
        <?= $block->escapeHtml($block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()), ['span']) ?>
    <?php endif; ?>
    <?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>           

                                                            
1
  • Thanks for your reply.. Jaydeep But it is not working, still facing the same issue. Nov 22 '21 at 8:00
0

Please try to remove this condition <?= $storeId == 2 ? on the below lines in the same code, like:

<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()) ?>"
        style="display:none;";
    ><?= $block->escapeHtml($block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()), ['span']) ?></span>
        <?= $block->escapeHtml($block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()), ['span']) ?>
0

I guess you are struggling with a Bug in Magento 2.4.3 which is discussed in a couple of Magento tickets on GitHub (e.g. https://github.com/magento/magento2/issues/33798 )

Solution would be either a patch as described here: https://github.com/magento/magento2/issues/33856#issuecomment-904606945

To make it work on Magento 2.4.3 without having to switch to unstable develop branch, you can create a patches/composer/ISSUE-33856-magento-disable-currency-number-formatter.patch file with following content:

diff --git a/Model/Currency.php b/Model/Currency.php
index 65b47d7..f9943da 100644
--- a/Model/Currency.php
+++ b/Model/Currency.php
@@ -365,10 +365,6 @@ class Currency extends \Magento\Framework\Model\AbstractModel
         */
        $price = sprintf("%F", $price);

-        if ($this->canUseNumberFormatter($options)) {
-            return $this->formatCurrency($price, $options);
-        }
-
        return $this->_localeCurrency->getCurrency($this->getCode())->toCurrency($price, $options);
    }

And then add the following to your composer.json:

{
   "extra": {
       "patches": {
           "magento/module-directory": {
               "Disable number formatter for Model/Currency ( https://github.com/magento/magento2/issues/33856 )": "patches/composer/ISSUE-33856-magento-disable-currency-number-formatter.patch"
           }
       }
   }
}

OR you make sure that Commit https://github.com/magento/magento2/commit/ae304d43cd36322b1ff8145d70c9b2e9aeb0cde is in your used Magento version which is supposed to be the final fix for this - according to https://github.com/magento/magento2/issues/33856#issuecomment-946761019

1
  • Current version 2.4.3-P1 does not yet contain this fix
    – dr_hanns
    Jan 7 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.