Remove "Gift Message for this Order" from Magento emails

In Magento 1.4.1.0 the new gift message facility appears to be missing some relevant lines from the templates to be able to disable the "Gift Message for this Order" area from the email template. Thankfully, its an extremely quick fix. Open up ./app/design/frontend/base/default/template/email/order/items.phtml and wrap the final table with a conditional statement.
<?php if(Mage::getStoreConfig('sales/gift_messages/allow_items')): ?>
  <table>
    ...
  </table>
<?php endif; ?>
The resulting file will then look something like this
<?php $_order = $this->getOrder() ?>
<table cellspacing="0" cellpadding="0" border="0" width="100%" style="border:1px solid #bebcb7; background:#f8f7f5;">
 <thead>
 <tr>
 <th align="left" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Item') ?></th>
 <th align="left" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Sku') ?></th>
 <th align="center" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Qty') ?></th>
 <th align="right" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Subtotal') ?></th>
 </tr>
 </thead>

 <?php $i=0; foreach ($_order->getAllItems() as $_item): ?>
 <?php if($_item->getParentItem()) continue; else $i++; ?>
 <tbody<?php echo $i%2 ? ' bgcolor="#eeeded"' : '' ?>>
 <?php echo $this->getItemHtml($_item) ?>
 </tbody>
 <?php endforeach; ?>

 <tbody>
 <?php echo $this->getChildHtml('order_totals') ?>
 </tbody>
</table>

<br />

<?php if(Mage::getStoreConfig('sales/gift_messages/allow_items')): ?>
<table cellspacing="0" cellpadding="0" border="0" width="100%" style="border:1px solid #bebcb7; background:#f8f7f5;">
 <thead>
 <tr>
 <th align="left" bgcolor="#d9e5ee" style="padding:3px 9px"><strong><?php echo $this->__('Gift Message for this Order') ?></strong></th>
 </tr>
 </thead>

 <tbody>
 <?php if($_order->getGiftMessageId() && $_giftMessage = $this->helper('giftmessage/message')->getGiftMessage($_order->getGiftMessageId())): ?>
 <tr>
 <td colspan="4" align="left" style="padding:3px 9px">
 <strong><?php echo $this->__('From:'); ?></strong> <?php echo $this->htmlEscape($_giftMessage->getSender()) ?>
 <br /><strong><?php echo $this->__('To:'); ?></strong> <?php echo $this->htmlEscape($_giftMessage->getRecipient()) ?>
 <br /><strong><?php echo $this->__('Message:'); ?></strong><br /> <?php echo $this->htmlEscape($_giftMessage->getMessage()) ?>
 </td>
 </tr>
 <?php endif; ?>
 </tbody>
</table>
<?php endif; ?>
[syntaxhighlighter]
  • Thanks for this, it helped me out. I'd just like to point out a typo in the file to edit, it should read: app/design/frontend/base/default/template/email/order/items.phtml

    • Bit of a blind mistake by me there! I've corrected it with the right path.

  • This looks great for removing the whole gift message for order. i came across this post after looking for info on removing the 'to' and 'from' fields in the gift message area, could this method be altered for that purpose ?

    • Sure can, make an extra module to piggyback off GiftMessage and pop this in its system.xml

      
       
       
       
       
       
       text
       100
       1
       1
       0
       
       
       
       select
       adminhtml/system_config_source_yesno
       1
       1
       1
       0
       
       
       
       select
       adminhtml/system_config_source_yesno
       1
       1
       1
       0
        
       
       
       
       
       
      
      

      Then just change the template file to this:

      < ?php if(Mage::getStoreConfig('sales/gift_messages/show_from')): ?>
      < ?php echo $this->__('From:'); ?> < ?php echo $this->htmlEscape($_giftMessage->getSender()) ?>
      < ?php endif; ?>
      < ?php if(Mage::getStoreConfig('sales/gift_messages/show_to')): ?>
      
      < ?php echo $this->__('To:'); ?> < ?php echo $this->htmlEscape($_giftMessage->getRecipient()) ?> < ?php endif; ?>

      You're lucky I'm feeling generous 😉

      • whoa that's awesome - cheers! 🙂
        will let you know how it goes

  • Tiago Rodrigues

    Thanks for your tip. I was looking at everthing and didn't found where the bug was coming from.

  • Hi, thanks for the tip. To keep this hack update-safe isn't it recommended to save the edited file under app/design/frontend/default/NAMEOFYOURTEMPLATE/template/email/order/items.phtml?

    Cheers, Patrick

  • Pingback: Wöchentliche Linktipps | User Agent - Websites, Online-Marketing, Berlin()

  • Hi. It works. Thanks a lot. Daina

  • nice work, tnx 🙂

  • We weren't deleting the messages from the email, we were modifying the gift messages system to allow generic comments to be added to an order. Thanks for helping me find the template to enable us to modify the text.