-
-
Save luancschmitz/48983d32c0f1e62280fc123feced7899 to your computer and use it in GitHub Desktop.
Formating price on JS for Magento 2
This file contains 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