I have displayed the address information on the registration page. Now I want to change all of these required items to non-required. How to change it, or how to delete the Street Address, City, State/Province, Zip fields. Can anyone help me solve this problem? thank you very much
Hello @allenlai
If you want to make any changes in registration form, You can simply override default register.phtml
Firstly add the below code in your layout file app/design/frontend/theme_dir/theme_name/layout/custom.xml
<customer_account_create> <reference name="customer_form_register"> <action method="setTemplate"> <template>custom/persistent/customer/form/register.phtml</template> </action> </reference> </customer_account_create>
After this overide register.phtml
From path :
app/design/frontend/base/default/template/persistent/customer/form/register.phtml
To path :
app/design/frontend/theme_dir/theme_name/template/custom/persistent/customer/form/register.phtml
And here you can make changes related to delete the Street Address, City, State/Province, Zip fields or remove required field option.
If my answer is useful, please Accept as Solution & give Kudos.
I understand yours, I am also doing this, but now remove the Street Address, City, State/Province, Zip fields directly in the register.phtml file will still be verified, how to solve this?
Hello @allenlai ,
Below way you can display address fields using customer_account_create.xml:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="customer_form_register"> <arguments> <argument name="show_address_fields" xsi:type="boolean">true</argument> </arguments> </referenceBlock> </body> </page>
otherwise, you can use an extension for it https://github.com/karliuka/m2.ShowAddressFields
--
If my answer is useful, please Accept as Solution & give Kudos