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.
Also find the below screenshot for the detail page.
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).