-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Price Format is overridden by a JavaScript in Product View #3834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@elenleonova please check. Is this the correct way to check price format? I don't think so. |
@jaimestuardo could you specify Magento version used? |
@veloraven This issue is present on 2.1.0 and 2.1.1. I've also reported the issue here: #6362 |
@lgarridoj |
Hello, Thank You very much |
[TSG] Backporting for 2.1 (pr65) (2.1.17)
Hello,
I have changed price format in es.xml file that is located under zendframework1 folder. In my case, price format is something like this: $ 99.990
Well... after I made the change and wait some time for the changes to make effect, it worked in all the site, that is, price appears as I want but in product view page.
When I load product details page, I can see that the page is loaded with the corect price format, however, after about 0,5 seconds, the price changes to $99.990,00. It is curous, isn't it?
That behaviour suggested me that there is some JavaScript that something do with the price, so I saw page code using Firebug and I saw this code:
`<script>
</script>`
After some investigation, I found that this piece of code is rendered in product/view/form.phtml template
When I opened it, I have found this code:
priceBoxes.priceBox({'priceConfig': <?php /* @escapeNotVerified */ echo $block->getJsonConfig() ?>});
Then, I opened block class file, finding this code:
` public function getJsonConfig()
{
/* @var $product \Magento\Catalog\Model\Product */
$product = $this->getProduct();
`
I can see that price format is retrieved in $this->_localeFormat->getPriceFormat().
Finally, I have opened framework/Locale/Format.php file to see this code:
` /**
* Functions returns array with price formatting info
*
* @param string $localeCode Locale code.
* @param string $currencyCode Currency code.
* @return array
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getPriceFormat($localeCode = null, $currencyCode = null)
{
$localeCode = $localeCode ?: $this->_localeResolver->getLocale();
if ($currencyCode) {
$currency = $this->currencyFactory->create()->load($currencyCode);
} else {
$currency = $this->_scopeResolver->getScope()->getCurrentCurrency();
}
$localeData = (new DataBundle())->get($localeCode);
$format = $localeData['NumberElements']['latn']['patterns']['currencyFormat']
?: explode(';', $localeData['NumberPatterns'][1])[0];
$decimalSymbol = $localeData['NumberElements']['latn']['symbols']['decimal']
?: $localeData['NumberElements'][0];
$groupSymbol = $localeData['NumberElements']['latn']['symbols']['group']
?: $localeData['NumberElements'][1];
The line $localeData = (new DataBundle())->get($localeCode); passes "es_ES" as the locale which is getting wrong locale values, not the values configured in es.xml file of Zendframework1.
I have used this code in Format.php to test:
$localeData = (new DataBundle())->get($localeCode); print_r($localeData['NumberPatterns'][1]); die;
With that, I checked that with the locale code "es_ES", this format is returned: ¤ #,##0.00. That format is not set in es_ES because if I see es_ES.xml file, this appears:
`
` I think this needs to be changed so that if could get the correct format as the whole site does.Regards
Jaime
The text was updated successfully, but these errors were encountered: