3

How to override addtocart.phtml files to change "Add to cart" button name.

0

3 Answers 3

5

You can use theme translation at here.

Create {LanguageCode}.csv at

 __/app
     |__/design
       |__/frontend
         |__/<Vendor>
           |__/<theme>
             |__/i18n
               |-- {LanguageCode}.csv

At this csv, "Add to Cart","MYCart".

See more detail at https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/translations/xlate.html

After that, you need to run static content deploy for getting affect of the translation.

2
  • That a good criteria to update just title all over the website. +1 Apr 10, 2019 at 10:14
  • Great answer and Better criteria to update through translation dictionaries. +1 Apr 10, 2019 at 10:16
2

Try overide with you theme file

Copy the file from below path

vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml

then paste it in below path

app/design/frontend/{Package}/{theme-name}/Magento_Catalog/templates/product/view/addtocart.phtml

clean cache and check.

EDIT :

In order to change label see @Amit answer, that would be simple.

1

You need to overwrite addtocart.phtml file with in your theme directory.

Copy the addtocart.phtml file from

vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml

to

app/design/frontend/<vendor-name>/<theme-name>/Magento_catalog/templates/product/view/addtocart.phtml

and make edit as you wants on this phtml file.

Flush the cache and refresh the page. I hope this helps.

3

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.