Magento: Select Customer Group at Registration

10,159

Solution 1

Check your config.xml:

<frontend>
    <routers>
        <customer>
            <args>
                <modules>
                    <WACI_Customer before="Mage_Customer_AccountController">
                        WACI_Customer
                    </WACI_Customer>
                </modules>
            </args>
        </customer>
    </routers>
</frontend>

Should be:

<frontend>
    <routers>
        <customer>
            <args>
                <modules>
                    <WACI_Customer before="Mage_Customer">WACI_Customer</WACI_Customer>
                </modules>
            </args>
        </customer>
    </routers>
</frontend>

You also need to pay attention with:

<WACI_Customer before="Mage_Customer">WACI_Customer</WACI_Customer>

and

<WACI_Customer before="Mage_Customer">
    WACI_Customer
</WACI_Customer>

You have to make sure no empty spaces between <tag> and content and </tag>

Solution 2

See below URL I think it is very help full to you.

How to let customer choose customer group at registration

http://www.magentocommerce.com/boards/viewthread/24208/

selecting customer group during registration in magento

http://sabujcse.wordpress.com/2010/03/09/selecting-customer-group-during-registration-in-magento/

How to Add Customer Group field while register in magento

http://xhtmlandcsshelp.blogspot.in/2010/12/add-customer-group-while-register-in.html

How to add group in register form

http://sapnandu-magento.blogspot.in/2011/07/how-to-add-group-in-register-form.html

Share:
10,159
Bosworth99
Author by

Bosworth99

I'm a front-end engineer and designer with over fifteen years of continuous experience. I have a passion for bulletproof architecture, airtight code, and beautiful layout. I'm keenly interested in how humans interface with digital systems, and strive to make that experience natural and compelling. Want to connect? Facebook LinkedIn GitHub Cheers!

Updated on June 13, 2022

Comments

  • Bosworth99
    Bosworth99 almost 2 years

    Trying to add a group_id radio button set in Magento Pro v1.11

    Following along with
    http://phpmagento.blogspot.com/2012/01/how-to-show-customer-group-selecter-in.html and
    http://developersindia.info/magento/magento-override-frontend-controller.html,
    which is working to a point, but the group_id is not getting written to the db.

    my module, thus far:

    Directory Structure

    app/code/local
    - WACI
    -- Customer
    --- controllers
    ---- AccountController.php
    --- etc
    ---- config.xml
    



    config.xml

    <config>
        <modules>
            <WACI_Customer>
                <version>0.1.0</version>
            </WACI_Customer>
        </modules>
        <global>
            <fieldsets>
                <customer_account>
                    <group_id><create>1</create></group_id>
                </customer_account>
            </fieldsets>
        </global>
        <frontend>
            <routers>
                <customer>
                    <args>
                        <modules>
                            <WACI_Customer before="Mage_Customer_AccountController">
                                WACI_Customer
                            </WACI_Customer>
                        </modules>
                    </args>
                </customer>
            </routers>
        </frontend>
    </config>
    



    AccountController.php

    <?php
    /**
     *Customer account controller
     *
     * @package     WACI_Customer
     */
    
    require_once Mage::getModuleDir('controllers', 'Mage_Customer').DS.'AccountController.php';
    
    class WACI_Customer_AccountController extends Mage_Customer_AccountController
    {
    
        /**
        * Create customer account action
        */
        public function createPostAction()
        {
    
    // contents of createPostAction(), with some extra logic
    
                /**
                 * Initialize customer group id
                 */
    
                /* catch groupid at account creation */
    
                if($this->getRequest()->getPost('group_id')){ 
                    $customer->setGroupId($this->getRequest()->getPost('group_id'));
                } else {
                    $customer->getGroupId(); 
                } 
    
    
    
     // rest of method
    
        }
    
    }
    




    theme../persistent/customer/form/register.phtml

    <div class="input-box">
        <label for="group_id"><?php echo $this->__('Select your customer group') ?></label><br />
        <?php 
            $groups = Mage::helper('customer')->getGroups()->toOptionArray();
            foreach ($groups as $group){
                echo '<input type="radio" name="group_id" value="'.$group['value'].'" class="validate-radio" >'.$group['label'].'</input><br/>';
            }
        ?>
    </div>
    

    So, the radio buttons with the groups show up fine at registration, but the data isn't being written to the db, as group still shows as general in the admin/manage customers

    • I don't really want to modify core files, as the article describes,
    • I'm not certain that I'm properly overwriting the mage accountController class (maybe theres a better way to do this?)

    What am I mucking up?

  • Bosworth99
    Bosworth99 over 11 years
    That was it. Thx. Config.xml makes my nose bleed.
  • Bosworth99
    Bosworth99 over 11 years
    I can google too ;D Thx - but I looked through all these already.
  • paddotk
    paddotk over 11 years
    Which of the 71 config.xml's do you mean?
  • paddotk
    paddotk over 11 years
    He posted code but not the location of the config.xml, so I really wouldn't know which one..