List item options in magento email template

List item options in magento email template

September 23, 2026 · Illustrated author avatarBy Stefan Bogdanescu
List item options in magento email template

List Item Options in Magento Email Template: A Comprehensive Guide

As an experienced developer, I understand how frustrating it can be when you’re trying to customize your Magento email templates but can’t seem to get the item options to display correctly. In this post, we’ll break down the process of adding custom item options to your Magento order confirmation emails.

Understanding the Default Email Template Structure

Before we dive into the solution, let’s first understand how the default Magento email template is structured:

  1. Email Templates: You can find these in app/design/frontend/base/default/template/email/order.
  2. Order Items Layout: The order items layout is located at app/design/frontend/base/default/template/email/order/items/order/default.phtml.

In the default.phtml file, you’ll notice a section dedicated to displaying item options:

<?php if ($this->getItemOptions()): ?>
    <dl style="margin:0; padding:0;">
        <?php foreach ($this->getItemOptions() as $option): ?>
            <dt><strong><em><small><?php echo $option['label'] ?></small></em></strong></dt>
            <dd style="margin:0; padding:0 0 0 9px;">
                <?php echo (isset($option['print_value']) ? $option['print_value'] : nl2br($this->escapeHtml($option['value']))) ?>
            </dd>
        <?php endforeach; ?>
    </dl>
<?php endif; ?>

The Issue with Custom Templates

When you create a custom email template, as described in the links provided (http://www.webspeaks.in/2011/06/customize-new-order-email-template-in.html and http://www.magentocommerce.com/boards/viewthread/43928/), you’re likely to face an issue where the item options aren’t being displayed correctly, even when using the default.phtml code.

The core problem lies in how Magento handles item options within your custom template. By default, it doesn’t carry over the item options data to your new template structure.

The Solution: Accessing Item Options Manually

To resolve this issue, you need to manually access and display the item options for each product in your order.

First, make sure you have a loop that iterates through all the items in the order:

<?php $_order = $this->getOrder(); ?>
<?php foreach ($_order->getAllItems() as $_item): ?>
    <?php if($_item->getParentItem()) continue; else: ?>
        <!-- Your item details go here -->
    <?php endif; ?>
<?php endforeach; ?>

Next, for each item, you can retrieve the options using getOptions():

<?php foreach ($_item->getOptions() as $_option): ?>
    <strong><em><small><?php echo $_option->getLabel() ?></small></em></strong>

    <?php if ($_option->getPrintValue()): ?>
        <dd style="margin:0; padding:0 0 0 9px;">
            <?php echo nl2br($this->escapeHtml($_option->getValue())) ?>
        </dd>
    <?php endif; ?>
<?php endforeach; ?>

This code will loop through all the options for each item in the order and display them as key-value pairs.

Conclusion

Customizing Magento email templates can be a powerful way to enhance your customer’s shopping experience. By understanding how to manually access and display item options, you can ensure that all relevant information is included in your custom emails.

Remember to test your changes thoroughly after making any modifications to ensure they function correctly across different devices and browsers.

If you found this guide helpful, feel free to explore our other Magento tutorials and resources at Laravel Company. We’re always updating with the latest tips and tricks for the Magento community.

Themes Email Orders Errors

Our network