Customer Attributes for Magento 2 extension adds customer attributes to the Registration Form to collect customer information. The value from the custom customer attributes will be displayed on My Account Page and added to Customer Detail Page, Customer Grid as well as Order Detail in the backend.
2. How Does It Work?
2.1 General config
Go to Stores ⇒ Configuration ⇒ BSSCommerce ⇒ Customer Attributes.
In Enable, choose Yes to enable the extension or No to disable it.
*Note: The Enable config only affects frontend display. Other backend functions aren’t affected by this config.
In Allow Dowload Customer Attribute File: choose Yes to allow downloading the file uploaded to customer attribute or No to restrict downloads.
In Title of Customer Attributes, enter the name for the customer attributes block. This title will be displayed in Registration Form and My Account Page.
2.2 Create new customer attributes
Go to Customers ⇒ BSSCommerce ⇒ Customer Attributes.
Customer Attributes Grid which displays all customer attributes created by admin. The Customer Attributes Grid is equipped with all function like a default Magento 2 grid, including filter, column, mass action (delete, update status).
Click Add New Attribute button to create a new customer attribute. Then, you will see 3 tabs: Properties, Manage Labels, and Display Configuration.
In Default Label, enter a name for the customer attribute.
In Input Type, choose 1 of the 9 input types: Text Field, Text Area, Date, Yes/No, Multiple Select, Dropdown, Checkbox and Radio Button, File (Attachment).
- If you choose Multiple Select, Dropdown, Checkbox or Radio Button, add options for the customer attribute in Manage Options.
In Values Required, choose Yes to make the customer attribute compulsory to fill in; otherwise, choose No.
Advanced Attribute Properties:
In Attribute Code, enter a code for the customer attribute. No space allowed and no more than 30 symbols.
*Note: In case none value is entered for Attribute Code, the extension will automatically get the value of Default Label as value for this field.
In Input Validation for Customer, choose one of the following input types to be validated for the customer attribute: Decimal Number, Integer Number, Email, URL, Letters, and Letters (a-z, A-Z) or Numbers (0-9).
- Input Validation for Customer config is only enabled if the input type is text field and File (Attachment)
- If you choose File (Attachment) input type, there are several fields in Advanced Attribute Properties tab to take into account.
In Maximum File Size (bytes), enter a number to define the largest file size possibly uploaded.
In File Extensions, type allowed file extension that can be uploaded to the customer attribute. Each is separated by a comma.
2.2.2 Manage labels
Customer Attributes for Magento 2 extension supports multiple store view, so you can display different customer attribute labels per store view.
2.2.3 Display configuration
In Sort Order, set the order of appearance for the customer attribute in the Registration form.
*Note: The sort order set here will also decide the order of appearance of the attributes in the backend.
In Status, enable or disable the customer attribute.
In Display in Registration Form, choose Yes to add the customer attribute to Registration Form.
In Display in My Account Page, choose Yes to add the customer attribute to My Account Page.
In Display in Order Detail Page, choose Yes to add the customer attribute to Order Detail Page under Sales of Admin Panel.
In Display in Customer Grid, choose Yes to add the customer attribute to Customer Grid.
In Add to Order Confirmation Email, choose Yes to display the customer attribute in the Order Confirmation email.
In Add to New Account Email, choose Yes to display the customer attributes in New Account email.
In Add to Order Frontend, choose Yes to display the customer attributes on Order Detail Page under My Account.
*Note: You need to reindex data of Customer Grid whenever you make any change in Display in Customer Grid config.
2.3 Create a new email template with customer attributes
As above, customer attributes are possibly set to display on Order Confirmation email and New Account email.
First off, you need to create a new template which includes customer attributes variable. Please follow Marketing Email Templates Add New Template.
- New Order Confirmation email template
In Template section of Load default template, you can select among various default email templates, for example, New Order. Then, hit on Load template button.
Under Template Information, select Insert Variable… to add customer attributes to new order confirmation template.
Do not forget to enter Template Name and Save the new template.
Secondly, set this new template as the Order Confirmation email by going to Stores Configuration Sales Sales Emails Order.
In New Order Confirmation Template, uncheck Use system value box and choose the newly created email template.
On completing, please Save Config.
- New Account email template
Similarly, you can create a new template with customer attributes for New Account email.
In Template of Load default template section, choose New Account (Default) template and hit Load Template.
Under Template Information, enter Template Name and select Insert Variable… to add customer attributes to New Account template.
Then, Save Template.
To set this new template as the New Account template, please follow Stores Configuration Customers Customer Configuration and expand Create New Account Options.
In Default Welcome Email, unmark Use system value box. Then choose the newly created template. Save Config to complete the settings.
2.4 Display Customer Attributes
Display customer attributes in Registration Page:
*Note: Customer Attributes for Magento 2 extension only supports checkbox in the frontend while in the backend, the checkbox is displayed in multiple-selection type.
A New Account email will be sent to the register, which includes the customer attributes based on the admin’s configuration.
Display Customer Attribute in Account Information of My Account Page:
Customer attributes can also be displayed on Order Confirmation email:
And on Order Detail Page under My Account.
Go to Customers ⇒ All Customers.
Display customer attribute in Customer Grid:
Display customer attribute in Customer Detail Page:
Go to Sales Orders.
Display customer attribute in Order Detail Page:
3. Import Customer with Customer Attributes
Customer Attributes for Magento 2 extension allows importing customer with the created customer attributes by using the .csv file.
Firstly, prepare the file of customer information with customer attributes to import. All created customer attributes must be included in the import file with each customer attributes code listed in separate columns. Please make sure that all customer attribute codes are the same as attribute codes of existing customer attributes.
For customer attributes with the input type is a checkbox or radio button, use option’s ID instead of options’ value. For customer attributes with the input type is a dropdown or multiple select, fill in with correct options’ value.
Admins can also download the sample file by following System Import.
In Entity Type, choose Custom Main File to import new customers with customer attributes.
In Import Behavior, select one of the following actions:
- Add/Update complex data: New data is added to the existing attributes in the database.
- Delete Entities: Any existing data of entities in the import file is removed from the database of the stores.
- Custom Action: Admins can also override the import behavior by writing a custom option.
In Select file to Import, upload the file prepared earlier. Make sure that the size of the uploaded file is not more than 3M.
On completing, tap Check Data button in the upper-right corner. Wait for few seconds for the validation to perform.
If the import data is valid, the successful message will be displayed as in the screenshot. Click on Import button to process the import to the end of the data. Otherwise, there is any problem in data, the error message will appear. Just correct the invalid data and re-upload the file.