JavaScript Formating a price in Magento using JavaScript

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?

Answer:1

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)

Answer:2

I am using the following code to create a kendo numeric textbox. Html <input type='text' name='num_wks_or_mons' id='num_wks_or_mons' tabindex='5'/> Jquery $("#num_wks_or_mons").width(295)....

I am using the following code to create a kendo numeric textbox. Html <input type='text' name='num_wks_or_mons' id='num_wks_or_mons' tabindex='5'/> Jquery $("#num_wks_or_mons").width(295)....

I am using the Incapsuala Web Application Firewall. It allows me to display the Incapsula seal on the bottom left of my pages. However, I have a few pop up pages that I need to generate for some PDF ...

I am using the Incapsuala Web Application Firewall. It allows me to display the Incapsula seal on the bottom left of my pages. However, I have a few pop up pages that I need to generate for some PDF ...

I'm using the Google visualization API barchart. I need to be able to do a few things with the following code: Display Percentages along the bottom. If there is 213 total, 81 should show 38% http:/...

I'm using the Google visualization API barchart. I need to be able to do a few things with the following code: Display Percentages along the bottom. If there is 213 total, 81 should show 38% http:/...

  1. google.visualization.numberformat percentage

In a singlepage application I'd like to pass sensitive data during a page reload/refresh. Since the data is sensitive it should not be recovered, for example when a user leaves the domain and then ...

In a singlepage application I'd like to pass sensitive data during a page reload/refresh. Since the data is sensitive it should not be recovered, for example when a user leaves the domain and then ...

  1. pass data between components
  2. pass data between view controllers
  3. pass data between activities
  4. pass data between components react
  5. pass data between fragments
  6. pass data between components vue
  7. pass data between sibling components react
  8. pass data between scenes unity
  9. pass data between sibling components angular
  10. pass data between forms c#
  11. pass data between threads python
  12. pass data between views swiftui
  13. pass data between threads c++
  14. pass data between fragments android
  15. pass data between html pages
  16. pass data between controllers mvc
  17. pass data between controllers angularjs
  18. pass data between routes angular
  19. pass data between routes react
  20. pass data between step functions