Magento – Magento 2 – Product price change to 0.00 in product detail page for Non-US Locale

localemagento-2.0.4magento2

I am facing a very strange issue after the installation of Magento 2.0.4. I have create a product with the price $12 and change the locale from Magento configuration in backend.

Below is the screenshot for the listing page.

enter image description here

Also find the below screenshot for the detail page.

enter image description here

You might have noticed the difference between two screenshot. Yes, Product detail page shows $0.00 price while listing page has retain with the price what i have added.

Product details page automatically updates correct price to $0,00 After one or two seconds ( Javascript Updates).

Find the below code for it

$('[data-price-type="' + priceCode + '"]', this.element).html(priceTemplate({data: price}));

I have debug further in the code and find another javascript code that passes parameter to Magento 2 pricebox widget.

<script>
    require([
        'jquery',
        'Magento_Catalog/js/price-box'
    ], function($){
        var priceBoxes = $('[data-role=priceBox]');

        priceBoxes = priceBoxes.filter(function(index, elem){
            return !$(elem).find('.price-from').length;
        });

        priceBoxes.priceBox({'priceConfig': <?php /* @escapeNotVerified */ echo $block->getJsonConfig() ?>});
    });
</script>

Now i have checked the getJsonConfig() method,

  $product = $this->getProduct();

        if (!$this->hasOptions()) {
            $config = [
                'productId' => $product->getId(),
                'priceFormat' => $this->_localeFormat->getPriceFormat()
                ];
            return $this->_jsonEncoder->encode($config);
        }

        $tierPrices = [];
        $tierPricesList = $product->getPriceInfo()->getPrice('tier_price')->getTierPriceList();
        foreach ($tierPricesList as $tierPrice) {
            $tierPrices[] = $this->priceCurrency->convert($tierPrice['price']->getValue());
        }
        $config = [
            'productId' => $product->getId(),
            'priceFormat' => $this->_localeFormat->getPriceFormat(),
            'prices' => [
                'oldPrice' => [
                    'amount' => $this->priceCurrency->convert(
                        $product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue()
                    ),
                    'adjustments' => []
                ],
                'basePrice' => [
                    'amount' => $this->priceCurrency->convert(
                        $product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount()
                    ),
                    'adjustments' => []
                ],
                'finalPrice' => [
                    'amount' => $this->priceCurrency->convert(
                        $product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue()
                    ),
                    'adjustments' => []
                ]
            ],
            'idSuffix' => '_clone',
            'tierPrices' => $tierPrices
        ];

I did lot of debugging through the code and come to the conclusion that they are using ICUDATA for locale support.

I am stuck with this all thing, It seems it is PriceFormat issue.

Please make sure this issue arise only for certain Locale options like Persion (Iran).

Best Answer

this issue has been resolved , kindly update your Magento2 to latest Stable version

if you have installed from GIT & Composer follow these steps :

  • Than you must stach your changes
  • GIT PULL Latest Stable Branch i.e. 2.1
  • Composer Update
  • Upgrade Magento ( bin/magento setup:upgrade)

else if you have installed using zip folder download than download latest from magento website and override all files using new zip than you need to clear cache and run

bin/magento setup:upgrade
Related Topic