How to add a new column in customer register?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 ano atrás
I am new comer for NopCommerce, my target is to save the data into the database when changing the customer information for this added column in customer table, also need to display the data on the page. So I added the code like below, how can I meet my target? thanks.

Below I dont have customer.groupowner = model.groupowner, but the data also cannot be saved to the database, that's why I added that, fyi.

                    _customerSettings.groupownerEnabled = true;
                    if (_customerSettings.groupownerEnabled)
                    {
                        await _genericAttributeService.SaveAttributeAsync(customer, NopCustomerDefaults.groupownerAttribute, model.groupowner);
                        customer.groupowner = model.groupowner;

                    }
1 ano atrás
if you storing the value into the customer table then no need to store in generic attribute you can delete the code
      await _genericAttributeService.SaveAttributeAsync(customer, NopCustomerDefaults.groupownerAttribute, model.groupowner);
this line of code is not required

   _customerSettings.groupownerEnabled = true;
                    if (_customerSettings.groupownerEnabled)
                    {
                              customer.groupowner = model.groupowner;
                    }

using this thing your customer object will assign the model value, whatever you change into the model it will assign after that you need to update the customer object using the below line ( although nop is already updating the customer , but might be in your case you have added some different code ) please add this line in post method after assigning into an object


customer.GroupOwner = model.GroupOwner;
                        await  _customerService.UpdateCustomerAsync(customer);
1 ano atrás
Hi ILYAS PATEL,

Yes you are right, when I added the below code, everyting is fine. :-) Thanks so much.
      await _customerService.UpdateCustomerAsync(customer);
After this code, I can see the data has been changed in the db, cool. :-)

Happy New Year
1 ano atrás
Hi,

Noticed you managed to solve adding a new register field.

How would you add a dropdown in the customer registration form (instead of text input)
that's being populated based on previous STATE/PROVINCE selection.

Basically, the functionality is similar to Country vs. STATE/PROVINCE dependency. When the user selects a country the STATE / PROVINCE dropdown is populated accordingly.

Thanks for any support :)
1 ano atrás
Hi
If you want dropdown for country state

You just need to change setting
Https://yourstore.com/Admin/Setting/CustomerUser

Please check this SS https://ibb.co/0G2c7WN

Checked the country and state field from the customer setting
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.