I want to format my price in template, and I find some place told about Magento_Catalog/js/price-box, But I don't know how to use it, Anyone can help me show me how to do.

  • have you create custom theme in your magento? Dec 21, 2016 at 8:48
  • No need new theme, I just customized a part of cart template.
    – MrTo-Kane
    Dec 21, 2016 at 9:01
  • Magento_Catalog/js/price-box this is show js file Dec 21, 2016 at 9:02

1 Answer 1


1) Magento_Catalog/js/price-box is used for formatting price amount.

  function formatPrice(amount, format, isShowSign) {
  • amount: is price amount (is a number)

  • format is a Object, having some property: decimalSymbol, groupLength, groupSymbol, pattern, precision, ... One the checkout page, we can check window.checkoutConfig.priceFormat

enter image description here

  • isShowSign: is a Boolean value. Will show +/- (add/minus) sign to the price.

2) The good example for using the price box js is in One Page Checkout.

One the checkout page, the checkout config is stored in a global Js variable. We can check in Browser Console: window.checkoutConfig

enter image description here


         * Format shipping price.
         * @returns {String}
        getFormattedPrice: function (price) {
            return priceUtils.formatPrice(price, quote.getPriceFormat());

There is a note: quote.getPriceFormat() gets the value from window.checkoutConfig.priceFormat object.

[EDIT] we can use:

        window.orderPriceFormat = <?php /* @escapeNotVerified */ echo $this->helper('Magento\Tax\Helper\Data')->getPriceFormat($block->getStore()); ?>;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.