Skip to main content

Print Customer's Group Name on the transactional emails

For printing the customer’s group name on the order confirmation email,
Firstly, we need to copy the following file "app/code/core/Mage/Sales/Model/Order.php" to  "app/code/local/Mage/Sales/Model/Order.php" as core files shouldn't be changed.

In Order.php, we should add the following function. This function will return the customer group name.

public function getCustomerGroupName(){
    if ($groupId = $this->getCustomerGroupId()){
        $group = Mage::getModel ('customer/group')->load($groupId);
        if ($group->getId()){
            return $group->getCode();
        }
    }
    return '';
}

Finally, we need to add the following code on the email template to get the group name,
{{htmlescape var=order.getCustomerGroupName()}}

Cheers!!


Comments