Magneto 2: Need to remove decimal from price on product detail page





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I want to remove the decimal in price on product details page. Although it removes in listing page, but still showing decimal in discount and final price on product details page.



enter image description here










share|improve this question































    0















    I want to remove the decimal in price on product details page. Although it removes in listing page, but still showing decimal in discount and final price on product details page.



    enter image description here










    share|improve this question



























      0












      0








      0








      I want to remove the decimal in price on product details page. Although it removes in listing page, but still showing decimal in discount and final price on product details page.



      enter image description here










      share|improve this question
















      I want to remove the decimal in price on product details page. Although it removes in listing page, but still showing decimal in discount and final price on product details page.



      enter image description here







      magento2 price product-detail-page






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 10 mins ago









      Kirti Nariya

      1,252416




      1,252416










      asked Jan 21 at 9:21









      AneesAnees

      15712




      15712






















          2 Answers
          2






          active

          oldest

          votes


















          0














          The best way I could find is to change the priceFormat function from Magento_Catolag/js/price-utils.js inside my priceBox.js, so in your requirejs-config.js



          var config = {

          "map": {

          "*": {

          "priceBox" : "Vendor_ModuleName/js/price-box"

          }
          }
          };


          Copy the whole Magento_Catalog/js/price-box.js to your Vendor/ModuleName/view/frontend/web/js/price-box.js and after the use strict add:



          var globalPriceFormat = {

                  requiredPrecision: 2,

                  integerRequired: 1,

                  decimalSymbol: ',',

                  groupSymbol: ',',

                  groupLength: ','

              };


          Under this copy the formatPrice function from price-utils.js



          Change:



          function formatPrice(amount, format, isShowSign) {

          var s = '',

                      precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


          To



          function formatPriceHack(amount, format, isShowSign) {
          var s = '',

                      precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


          Also comment:



                  



          //precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;


          And change:



          i = stringPad('0', pad) + i;



          To inside formatPriceHack:



          i = utils.strPad('0', pad) + i;


          And last, change inside the reloadPrice function from priceBox:



          price.formatted = utils.formatPrice(price.final, priceFormat);


          To:



          price.formatted = formatPriceHack(price.final, priceFormat);


          That's it.






          share|improve this answer































            0














            Create file and use this code :



            => From :




            vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml




            => To :




            app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml




            this file is defined from MagentoFrameworkPricingRenderAmount



            The price itself is coming from this call:



            <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


            If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php)



            Update line no 24



            <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


            To



            <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>


            You need to override




            vendor/magento/module-catalog/view/base/web/js/price-utils.js




            To




            app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js




            and change the value of precision on line 38:



            var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,


            To



            var precision = 0,





            share|improve this answer
























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "479"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258530%2fmagneto-2-need-to-remove-decimal-from-price-on-product-detail-page%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              The best way I could find is to change the priceFormat function from Magento_Catolag/js/price-utils.js inside my priceBox.js, so in your requirejs-config.js



              var config = {

              "map": {

              "*": {

              "priceBox" : "Vendor_ModuleName/js/price-box"

              }
              }
              };


              Copy the whole Magento_Catalog/js/price-box.js to your Vendor/ModuleName/view/frontend/web/js/price-box.js and after the use strict add:



              var globalPriceFormat = {

                      requiredPrecision: 2,

                      integerRequired: 1,

                      decimalSymbol: ',',

                      groupSymbol: ',',

                      groupLength: ','

                  };


              Under this copy the formatPrice function from price-utils.js



              Change:



              function formatPrice(amount, format, isShowSign) {

              var s = '',

                          precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


              To



              function formatPriceHack(amount, format, isShowSign) {
              var s = '',

                          precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


              Also comment:



                      



              //precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;


              And change:



              i = stringPad('0', pad) + i;



              To inside formatPriceHack:



              i = utils.strPad('0', pad) + i;


              And last, change inside the reloadPrice function from priceBox:



              price.formatted = utils.formatPrice(price.final, priceFormat);


              To:



              price.formatted = formatPriceHack(price.final, priceFormat);


              That's it.






              share|improve this answer




























                0














                The best way I could find is to change the priceFormat function from Magento_Catolag/js/price-utils.js inside my priceBox.js, so in your requirejs-config.js



                var config = {

                "map": {

                "*": {

                "priceBox" : "Vendor_ModuleName/js/price-box"

                }
                }
                };


                Copy the whole Magento_Catalog/js/price-box.js to your Vendor/ModuleName/view/frontend/web/js/price-box.js and after the use strict add:



                var globalPriceFormat = {

                        requiredPrecision: 2,

                        integerRequired: 1,

                        decimalSymbol: ',',

                        groupSymbol: ',',

                        groupLength: ','

                    };


                Under this copy the formatPrice function from price-utils.js



                Change:



                function formatPrice(amount, format, isShowSign) {

                var s = '',

                            precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


                To



                function formatPriceHack(amount, format, isShowSign) {
                var s = '',

                            precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


                Also comment:



                        



                //precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;


                And change:



                i = stringPad('0', pad) + i;



                To inside formatPriceHack:



                i = utils.strPad('0', pad) + i;


                And last, change inside the reloadPrice function from priceBox:



                price.formatted = utils.formatPrice(price.final, priceFormat);


                To:



                price.formatted = formatPriceHack(price.final, priceFormat);


                That's it.






                share|improve this answer


























                  0












                  0








                  0







                  The best way I could find is to change the priceFormat function from Magento_Catolag/js/price-utils.js inside my priceBox.js, so in your requirejs-config.js



                  var config = {

                  "map": {

                  "*": {

                  "priceBox" : "Vendor_ModuleName/js/price-box"

                  }
                  }
                  };


                  Copy the whole Magento_Catalog/js/price-box.js to your Vendor/ModuleName/view/frontend/web/js/price-box.js and after the use strict add:



                  var globalPriceFormat = {

                          requiredPrecision: 2,

                          integerRequired: 1,

                          decimalSymbol: ',',

                          groupSymbol: ',',

                          groupLength: ','

                      };


                  Under this copy the formatPrice function from price-utils.js



                  Change:



                  function formatPrice(amount, format, isShowSign) {

                  var s = '',

                              precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


                  To



                  function formatPriceHack(amount, format, isShowSign) {
                  var s = '',

                              precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


                  Also comment:



                          



                  //precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;


                  And change:



                  i = stringPad('0', pad) + i;



                  To inside formatPriceHack:



                  i = utils.strPad('0', pad) + i;


                  And last, change inside the reloadPrice function from priceBox:



                  price.formatted = utils.formatPrice(price.final, priceFormat);


                  To:



                  price.formatted = formatPriceHack(price.final, priceFormat);


                  That's it.






                  share|improve this answer













                  The best way I could find is to change the priceFormat function from Magento_Catolag/js/price-utils.js inside my priceBox.js, so in your requirejs-config.js



                  var config = {

                  "map": {

                  "*": {

                  "priceBox" : "Vendor_ModuleName/js/price-box"

                  }
                  }
                  };


                  Copy the whole Magento_Catalog/js/price-box.js to your Vendor/ModuleName/view/frontend/web/js/price-box.js and after the use strict add:



                  var globalPriceFormat = {

                          requiredPrecision: 2,

                          integerRequired: 1,

                          decimalSymbol: ',',

                          groupSymbol: ',',

                          groupLength: ','

                      };


                  Under this copy the formatPrice function from price-utils.js



                  Change:



                  function formatPrice(amount, format, isShowSign) {

                  var s = '',

                              precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


                  To



                  function formatPriceHack(amount, format, isShowSign) {
                  var s = '',

                              precision = 0, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;


                  Also comment:



                          



                  //precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;


                  And change:



                  i = stringPad('0', pad) + i;



                  To inside formatPriceHack:



                  i = utils.strPad('0', pad) + i;


                  And last, change inside the reloadPrice function from priceBox:



                  price.formatted = utils.formatPrice(price.final, priceFormat);


                  To:



                  price.formatted = formatPriceHack(price.final, priceFormat);


                  That's it.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 21 at 10:16









                  gemig_holgemig_hol

                  591119




                  591119

























                      0














                      Create file and use this code :



                      => From :




                      vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml




                      => To :




                      app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml




                      this file is defined from MagentoFrameworkPricingRenderAmount



                      The price itself is coming from this call:



                      <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


                      If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php)



                      Update line no 24



                      <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


                      To



                      <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>


                      You need to override




                      vendor/magento/module-catalog/view/base/web/js/price-utils.js




                      To




                      app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js




                      and change the value of precision on line 38:



                      var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,


                      To



                      var precision = 0,





                      share|improve this answer




























                        0














                        Create file and use this code :



                        => From :




                        vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml




                        => To :




                        app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml




                        this file is defined from MagentoFrameworkPricingRenderAmount



                        The price itself is coming from this call:



                        <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


                        If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php)



                        Update line no 24



                        <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


                        To



                        <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>


                        You need to override




                        vendor/magento/module-catalog/view/base/web/js/price-utils.js




                        To




                        app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js




                        and change the value of precision on line 38:



                        var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,


                        To



                        var precision = 0,





                        share|improve this answer


























                          0












                          0








                          0







                          Create file and use this code :



                          => From :




                          vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml




                          => To :




                          app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml




                          this file is defined from MagentoFrameworkPricingRenderAmount



                          The price itself is coming from this call:



                          <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


                          If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php)



                          Update line no 24



                          <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


                          To



                          <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>


                          You need to override




                          vendor/magento/module-catalog/view/base/web/js/price-utils.js




                          To




                          app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js




                          and change the value of precision on line 38:



                          var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,


                          To



                          var precision = 0,





                          share|improve this answer













                          Create file and use this code :



                          => From :




                          vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml




                          => To :




                          app/design/frontend/VendorName/ModuleName/Magento_Catalog/templates/product/price/amount/default.phtml




                          this file is defined from MagentoFrameworkPricingRenderAmount



                          The price itself is coming from this call:



                          <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


                          If we take a look at the file that this method is created based on the class it's inheriting (/vendor/magento/framework/Pricing/Render/Amount.php)



                          Update line no 24



                          <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>


                          To



                          <?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer() , 0) ?>


                          You need to override




                          vendor/magento/module-catalog/view/base/web/js/price-utils.js




                          To




                          app/design/frontend/VendorName/ModuelName/Magento_Catalog/web/js/price-utils.js




                          and change the value of precision on line 38:



                          var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,


                          To



                          var precision = 0,






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 21 at 10:29









                          Rohan HapaniRohan Hapani

                          7,04631865




                          7,04631865






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f258530%2fmagneto-2-need-to-remove-decimal-from-price-on-product-detail-page%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              What other Star Trek series did the main TNG cast show up in?

                              Berlina muro

                              Berlina aerponto