In Magento I have a savings box, which calculates how much you save based on the difference between the regular and discount price.
Now I want that box to increase the saving amount based on the quantity. If you order 2 of the product you save twice as much. Calculating that number and updating the price in javascript is not the problem.
The problem is the number I calculate isn't formatted. How do I format that price using javascipt? I do want it to be dynamic so that I don't have to change it when I use an other currency.
In short
How do I format a number into a price in Magento using javascript?
Try this:
<?php
$priceFormat = Mage::helper('core')->jsonEncode(Mage::app()->getLocale()->getJsPriceFormat());
?>
<script>
formatCurrency(p.c_old_price, <?php echo $priceFormat ?>);
</script>
For more details see: https://himansuboity.wordpress.com/2014/09/30/magento-tip-how-to-get-the-store-price-format-by-javascript/
The suggested optionsPrice didn't work for me, since it has not JSON configuration (it only works for products containing options, which makes no sense for me! It seems to be obsolete Magento code)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With