1

I have created a custom check box field in billing.phtml(Magento 1.9.2.1), i want to assign customer group based on this field (i,e.. if the field is check the customer will be in one customer group and if the field is not checked the customer will be in another customer group.). how to do this ?

0

You can do by observing customer save before event.

        <customer_save_before>
            <observers>
                <unique_customer_save>
                    <type>singleton</type>
                    <class>Namespace_Module_Model_Observer</class>
                    <method>customer_save_before</method>
                </unique_customer_save>
            </observers>
        </customer_save_before>

Replace Namespace_Module with your module name.

class Namespace_Module_Model_Observer
{    
    public function customer_save_before($observer)
    {
        $group_id = 3; //Change this to your id
        $customer = $observer->getCustomer();
        $customer->setCustomerGroupId($group_id);
        //echo "<pre>"; print_r( $customer->getData() );
        Mage::log( $customer->getData() , null, 'customer_Before.log');        
    }

}

Change $group_id value to your value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.