I'm trying to get the Customer Group from the customer's order. I have the following code and I have commented the line that doesn't appear to be working;

<?php if($order->getCustomerId()):?>

    // Correctly gets the CustomerId from the $order
    <?php $customerId = Mage::getModel('customer/customer')->load($order->getCustomerId())?>

    // Here i'm trying to get the Customer Group but it's not being returned
    <?php $customer_group_id = Mage::getModel('customer/customer')->load($order->getCustomerGroupId()); ?>
    <?php $customerGroup = Mage::getModel('customer/group')->load($customer_group_id)->getCode() ?>

    <?php echo $customerGroup ?>

<?php endif; ?>

I wondered if someone could help me rectify this?

Thank you.

2 Answers 2


You should be nearly there. Actually the 7th line is not required and messes up the script

$customer = Mage::getModel('customer/customer')->load($order->getCustomerId())
$customerGroup = Mage::getModel('customer/group')->load($customer->getCustomerGroupId())->getCode();
  • Thanks @sander-mangel. For some reason it still doesn't echo out the customer group. Even though i know that the customer is a registered user assigned to a customer group. Dec 9, 2015 at 15:32
  • 1
    Got it. The last line needed to be: <?php $customerGroup = Mage::getModel('customer/group')->load($order->getCustomerGroupId())->getCode();?> Dec 9, 2015 at 15:35
  • Great, glad it works Dec 9, 2015 at 16:31

Try This;

<?php if ($order->getCustomerGroupId()): ?>
    <?php $customerGroup = Mage::getModel('customer/group')->load($order->getCustomerGroupId()); ?>
    <?php echo $customerGroup->getCustomerGroupCode(); ?>
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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