Tuesday, January 5, 2010

Show customer group in order e-mail (for redbeetstudio)

Problem: Show customer group in order e-mail.

Possible solution
In order for this to work in the e-mail template:
{{var order.getCustomerGroupName()}}
you have to create a method in the Order model (overwrite it or edit the core at your own risk).
function getCustomerGroupName(){
$group = Mage::getModel('customer/customer_group')->load($this->getCustomerGroupId());
if ($group->getId()){
return $group->getName();
return '';//or any default value if the customer is not in a group or is a guest


  1. Does this work in Community? Also, where in the order module (which line) does the code above need inserted into? Thx!

  2. Hello Mark
    The code above should be in the order model (Mage_Sales_Model_Order.php), but you shouldn't add it directly in this file. You should properly override the model and add your function. To override the model check this:


    I actually don't know for sure if it works on CE but I don't see any reason why it shouldn't.