Last active
September 27, 2022 12:15
-
-
Save cagartner/870a8b666fba7a0ccb414e83d0195189 to your computer and use it in GitHub Desktop.
Formating price on JS for Magento 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define( | |
[ | |
'jquery', | |
'Magento_Checkout/js/model/quote', | |
'Magento_Catalog/js/price-utils' | |
], | |
function ($,quote, priceUtils) { | |
"use strict"; | |
...... | |
formatedPrice = getFormattedPrice(price) | |
getFormattedPrice: function (price) { | |
//todo add format data | |
// var priceFormat = quote.getPriceFormat(); | |
// or create the format by yourself. | |
var priceFormat = { | |
decimalSymbol: '.', | |
groupLength: 3, | |
groupSymbol: ",", | |
integerRequired: false, | |
pattern: "$%s", | |
precision: 2, | |
requiredPrecision: 2 | |
}; | |
// you can use the quote.getPriceFormat when possible or | |
return priceUtils.formatPrice(price, priceFormat); | |
} | |
}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment