1

I am working with Magento 2.1.3 and i want to add some custom text before product's price in product details page.

1 Answer 1

1

You need to make changes in price-box.js which is placed at

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

Make sure you take this js in your custom theme folder and make changes on line number 22 near priceTemplate: '<span class="price"><%- data.formatted %></span>'

Add your custom text after <span class="price">

Some thing like this,

priceTemplate: '<span class="price">Price - <%- data.formatted %></span>'

Done.

7
  • i have made changes but i confuse where i place this file in my custom theme folder ?
    – Mohd Hasan
    Apr 18, 2018 at 5:49
  • Copy price-box.js from this path /vendor/magento/module-catalog/view/base/web/js/price-box.js And paste it at below path, /app/design/frontend/Custom/Theme/Magento_Catalog/web/js/price-box.js Create this path if not exists. And make changes at line number 22, like priceTemplate: '<span class="price">Price - <%- data.formatted %></span>' Run below commands at terminal, >php bin/magento s:up >php bin/magento setup:di:compile >php bin/magento setup:static-content:deploy -f >php bin/magento c:c Apr 18, 2018 at 6:04
  • i paste price-box.js in to above mention folder and i clean cache but nothing change.
    – Mohd Hasan
    Apr 18, 2018 at 6:09
  • Run below commands at terminal, >php bin/magento s:up >php bin/magento setup:di:compile >php bin/magento setup:static-content:deploy -f >php bin/magento c:c @MohdHasan Apr 18, 2018 at 6:10
  • Done ? @MohdHasan Apr 18, 2018 at 6:15

Your Answer

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

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