Assign group to the customer using dropdown or group code in Magento

January 5, 2016  |  1 Comments  |  by Raj (MagePsycho)  |  Magento

If you are looking for functionality which allows customers to select their required customer group at registration & checkout either by using group dropdown or group code, then Customer Group Selector / Switcher Extension is for you.

Customer-Group-Selector

1. Associate Customer Group Using Dropdown

You can show the selected list of customer groups as dropdown at registration, checkout and my account edit pages. So that customer can select the group of their choice while registration . This feature can be very handy for your B2B stores.

1.1 Group Dropdown at Registration

It’s pretty straight forward to have customer group dropdown at registration, see the settings below:

Customer Group Selector Type - Dropdown

Registration – Customer Group Dropdown

Note: If you are using your own customized registration template (.phtml), then you can simply use the following code in your template:

<!-- Customer Group Field Widget -->
<li>
<?php
echo $this->getLayout()
->createBlock('magepsycho_customerregfields/customer_widget_type')
->setObject($this->getFormData())
->setIsEditPage(false)
->toHtml()
?>
</li>
<!-- //Customer Group Field Widget -->

1.2 Group Dropdown at Checkout

You can also enable customer group dropdown at Checkout Page which will be shown at Billing Address form (as shown below).
In order to enable it, just make ‘Is Enabled to Checkout?’ to Yes from the setting.

Customer Group Selector Type - Dropdown at Checkout Page

Checkout – Customer Group Dropdown

Note: If you are using custom billing address template (.phtml) file, then you can simply use the following code:

<!-- Customer Group Field Widget -->
<li>
<?php
echo $this->getLayout()
->createBlock('magepsycho_customerregfields/customer_widget_type')
->setObject($this->getQuote())
->setIsEditPage(false)
->setFieldIdFormat('billing:%s')
->setFieldNameFormat('billing[%s]')
->toHtml()
?>
</li>
<!-- //Customer Group Field Widget -->

1.3 Group Dropdown at My Account Edit Page

If you want the customer group to be editable from My Account Edit page, you can simply enable it from the extension settings (refer below screenshot)

Customer Group Selector Type - Dropdown - My Account Edit Page

My Account Edit Page – Customer Group Dropdown –


Note: If you have customized edit page, then you can use following snippet of code in order to show the field in the form:

<!-- Customer Group Field Widget -->
<li>
<?php
echo $this->getLayout()
->createBlock('magepsycho_customerregfields/customer_widget_type')
->setObject($this->getCustomer())
->setIsEditPage(true)
->toHtml()
?>
</li>
<!-- //Customer Group Field Widget -->

2. Associate Customer Group Using Code

If you want to associate customer group based on some code, then this option is for you. It allows customers to enter group code and the customer will be assigned to the group associated with the code.
For this you just have to chose ‘Group Selector Type’ to ‘Group Code’ and add group codes from settings (refer to the below screenshot).

Group Settings: Customer Group Selector Type - Group Code

Group Settings: Customer Group Selector Type – Group Code

2.1 Group Code at Registration

Similarly to group dropdown, you can have group code field at Registration, Checkout and My Account Edit Page.

Registration Page - Customer Group Code

Registration Page – Customer Group Code

2.2 Group Code at Checkout

Checkout Page - Customer Group Code

Checkout Page – Customer Group Code

2.3 Group Code at My Account Edit Page

My Account Edit Page - Customer Group Code (Editable)

My Account Edit Page – Customer Group Code (Editable)

Note: You can use the same code as above if you have want to include the group selector field at registration, checkout & account edit pages.

(This extension comes bundled with Store Restriction Pro & Custom Login Redirect Pro)