I'm trying to put some custom text in an invoice template (a transactional mail). I am doing this by loading a block in the template. In here i want to use some logic to display some text based on GroupId.

In Invoice_new.html

{{block type='core/template' area='frontend' template='mailcomment/mailcomment.phtml' order=$order}}

**In my new file mailcomment.phtml

<?php $customergroup = $this->getData('order')->getCustomerGroupId(); 
if ($customergroup==7) 
echo ("Some custom text")?>

Unfortuntely this does not work. Can anybody tell me what i am doing wrong?

  • $this->getData('order') is given result?
    – Amit Bera
    Jan 21, 2015 at 11:05
  • I used an example for getting the payment method: $paymentmethod = $this->getData('order')->getPayment()->getMethodInstance()->getCode(); This works just fine. Jan 21, 2015 at 11:09
  • And this info i was trying to use: magento.stackexchange.com/questions/19015/… Jan 21, 2015 at 11:13
  • are you tried this thing $paymentmethod = $this->getData('order')->getPayment()->getMethodInstance()->getCode(); on mailcomment/mailcomment.phtml file?
    – Amit Bera
    Jan 21, 2015 at 11:19
  • Yes but that gets the paymentmethod in the variabel $customergroup. I would like this variable to contain the customergroupid. Jan 21, 2015 at 11:43

1 Answer 1


This seems OK, so leave it as it is:

{{block type='core/template' area='frontend' template='mailcomment/mailcomment.phtml' order=$order}}

Try changing your phtml file:

<?php if ($this->getOrder()->getCustomerGroupId() == 7): ?>
    <?php echo $this->__('Yes') ?>
<?php else: ?>
    <?php echo $this->__('No') ?>
<?php endif ?>

Your Answer

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

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