Search

Aug 18, 2015

Set type customer ( group_id ) from register form in Magento

Step 1: Go to admin -> System -> Config (default) -> Customer Config -> Create new account options (tab) -> Enable Automatic Assignment to Customer Group ( Set = No ) -> Save

Step 2: Edit file ../../Customer/controllers/AccountController.php (from Core file or Module file) 

public function createPostAction()
{
    .....
    $customer = $this->_getCustomer();

    // Start Mod

    if ($this->getRequest()->getPost('group_id')){
        $customer->setGroupId(intval($this->getRequest()->getPost('group_id')));
    } else $customer->getGroupId();

    // End Mod

    ......
    $customer->save();
    ......
}


Step 3: Create register form with name="group_id"

<div class="form-group">
    <label class="radio-inline" for="group_id">
        <input type="radio" name="group_id" value="3">Retailer</label>
    <label class="radio-inline" for="group_id">
        <input type="radio" name="group_id" value="4">Designer</label>
    <label class="radio-inline" for="group_id">
        <input type="radio" name="group_id" value="5">Hospitality</label>    
</div>

No comments:

Post a Comment