Using the customer group is a good way to restrict and change parts of your Magento store when a customer is logged in. A good example of this is if you are wanting to put restrictions in or show alternative banners based on a Wholesaler customer login. To get the customer group id from the current session we can use the code below:
1 2 |
<!--?php <br ?--> $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); ?> |
A quick example of using this code in our template would be to show a different banner for trade customers on the homepage:
1 2 3 4 5 6 7 8 |
<!--?php <br ?--> $trade_customer_group_id = 5; $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); if($groupId = $trade_customer_group_id){ echo '<img src="tradebanner.jpg" alt="" />'; } else { echo '<img src="customerbanner.jpg" alt="" />'; } ?> |
Leave a reply