checkout - magento changing customer group of guest user -
i have custom field in onepage checkout, used in model\observer.php
set customer group using following:
$customer = mage::getsingleton("customer/session")->getcustomer(); $customer->setgroupid($newgroupid)->save();
this works great, , i'm doing change tax in cart.
however, people checking out guest throws error:
customer email required
is there way of setting customer group guest, second not logged in group example?
check user session set customer email address.
$session = mage::getsingleton('customer/session'); $customer = $session->getcustomer(); if($session->isloggedin()) { $customer->setgroupid($newgroupid)->save(); } else { $customer->setemail($customer->getdata('email')); $customer->setgroupid('2'); // assuming 'guest' groupd id 2 $customer->save(); }
Comments
Post a Comment