Frage

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?

War es hilfreich?

Lösung

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

Andere Tipps

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.

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

Exact code is as follow in app/design/frontend/[themepackage]/[theme]/Magento_Customer/layout/customer_account_create.xml

    <?xml version="1.0"?>
    <!--
    /**
     * Copyright © 2015 Magento. All rights reserved.
     * See COPYING.txt for license details.
     */
    -->
    <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>
    </page>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top