How to override addtocart.phtml files to change "Add to cart" button name.
3 Answers
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.
-
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
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.
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.
-
-
It seems you have not created a custom theme yet. for the best practice you need to create a custom theme and apply it. Please following the official guide for it: devdocs.magento.com/guides/v2.2/frontend-dev-guide/themes/… and devdocs.magento.com/guides/v2.2/frontend-dev-guide/themes/… Apr 10, 2019 at 11:02
-
Also I agree with @Amit answer, that would be simple in order to change just label. Apr 10, 2019 at 11:04