We are running on Magento 2.3 and I want to remove the currency symbol from the product price and also remove the decimals when the price is .00
How can we achieve that?
I already changed the file: app/design/frontend/{{namespace}}/{{theme_name}}/Magento_Catalog/templates/product/price/amount/default.phtml
to:
<?php /* @escapeNotVerified */ $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer(), 0) ?>
That works fine for the productlist page, but not the productpage.
Updating /vendor/magento/module-catalog/view/base/web/js/price-utils.js
to var precision = 0,
does not work well, because all prices do not have decimals in that case. But we only want to remove the decimals when the price is .00
How can we achieve that and also remove the currency symbol?
Best Answer
I am not sure what you want is this but check it.
For the product page I think you can look at
vendor/magento/module-catalog/view/base/web/js/price-box.js
and around line no 149 you will see
price.formatted = utils.formatPrice(price.final, priceFormat);
You check it in
console.log(price.formatted);
it will show the string which is displaying at the product page.So you can change it as your requirement like below.
Note : You should not change the core file