How to extend newcustomer.phtml in Magento 2.3?
-
15-04-2021 - |
Question
I want to change the default text
-- Creating an account has many benefits: check out faster, keep more than one address, track orders and more.
So how would i extend the path vendor/magento/module-customer/view/frontend/templates/newcustomer.phtml.
Any help is appriciated.
La solution
if you only wants to modify the text i suggest to use translations: https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/translations/xlate.html
translations are not used only for translating to another language, but also to modify the text in a given language.
you can use/create a translation file in a custom module, for example:
app/code/[Vendor]/[Module]/i18n/en_US.csv
or the translation file from your theme:
app/design/frontend/[Vendor]/[theme]/i18n/en_US.csv
You can find the translation key inside of __(..)
in your template, which in your case is Creating an account has many benefits: check out faster, keep more than one address, track orders and more.
. Adding the following line to a translation file, will modify the output
"Creating an account has many benefits: check out faster, keep more than one address, track orders and more.","New label to create an account"
Still if you need to modify the template, the best is to override it into a child template: https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/templates/template-override.html
for example to override
vendor/magento/module-customer/view/frontend/templates/newcustomer.phtml
copy it into
app/design/frontend/[Vendor]/[theme]/Magento_Customer/templates/newcustomer.phtml
for both approaches you need to clear the cache to see the result.