1

I was looking but I can not find a solution that will work.


During registration on Magento 2.1.11, I would like to display the following additional fields:

  • address (required)
  • mobile phone (required)
  • company name (required)
  • company's registration number (required)

It is a B2B wholesale site, so I only sell for companies. I would like all these fields to be required during registration.

maybe any have a solution?

  • have you created customer address attributes for mobile phone (required), company name (required) & company's registration number (required)? – Abdul Jan 2 '18 at 12:47
  • when I login to my account (as a customer) then I see these fields. Only the field with the company's registration number is missing. during registration visible only fields: first name, last name, e-mail & password – Sylvester Jan 2 '18 at 12:52
  • are you add company's registration number right? all others fields already display right now. – Abdul Jan 2 '18 at 12:55
  • unfortunately I do not know where I can add an extra field "company's registration number". – Sylvester Jan 2 '18 at 13:01
  • But my question others fields already display? For eg. Company, Tell Phone , Fax – Abdul Jan 2 '18 at 13:05
2

Create customer_account_create.xml file your current active theme

For eg.

app/design/frontend/{YOUR_PACKAGE}/{YOUR_THEME}/Magento_Customer/layout/customer_account_create.xml

After add below code for display address field in registration form

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
       <referenceBlock name="customer_form_register">
            <action method="setShowAddressFields">
                <argument name="show.address.fields" xsi:type="boolean">true</argument>
            </action>
       </referenceBlock>
    </body>
</page>

After run below commands

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:clean
  • Thanks Abdul, good job all works! I gave you a vote. I'm missing now only the field for the "company's registration number". Do you know in which file can I add it? I would also like to change the field "name of the company" to be required, will it do it in the database? currently this field is not marked as required. – Sylvester Jan 2 '18 at 14:12
  • have you created customer address attribute for this? – Abdul Jan 3 '18 at 4:52
2

I assume that all the attributes you want to show in the registration form are already introduced in Magento.

To show the address fields:

  • create the file customer_account_create.xml under app/design/frontend/[themepackage]/[theme]/Magento_Customer/layout folder.

  • Now paste below code in this file:

<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">
        <action method="setShowAddressFields">
            <argument name="show.address.fields" xsi:type="boolean">true</argument>
        </action>
    </referenceBlock>
</body>

The main thing here is that you need to set true for setShowAddressFields argument.

Please let me know if it helped.

  • Your answer seems to be the most correct! I created customer_account_create.xml with script and added it to the folder: app/design/frontend/MGS/Ethan/Magento_Customer/layout/customer_account_create.xml. I have refreshed XAMPP but unfortunately these fields are still not visible. Maybe I need to update with the magento command? – Sylvester Jan 2 '18 at 13:14
0

How to display the address fields in the registration form Magento 2.2.5 & 2.2.4

  1. Go to /vendor/magento/module-customer/view/frontend/layout/customer_account_create.xml

and add a code : Line no : 20 Under

true enter image description here

  1. change the setting from Magento 2 admin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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