I want to add extra information in a transactional email when the order has a product which is backordered.

I know where and how to edit the email templates following this guide: http://www.flyingtophat.co.uk/blog/2011/08/31/magento-displaying-custom-attributes-in-emails.html

The problem is I don't know how to check if the order has backorder items. I found that the table sales_flat_order_item has a a field qty_backordered but it has no value and is NULL.

I can get the value of the field with the following code

echo $_item->getQtyBackordered();

My question is, why is the value of the field NULL? How can I make sure the field gets populated with the amount of items which are backordered? Or maybe there is another solution?

The only thing I actually need is to check if a placed order has at least 1 item backordered (so I can display extra backorder information).

5 Answers 5


To add it to the Email:


and find this ~line 31:

<strong style="font-size:11px;"><?php echo $this->htmlEscape($_item->getName()) ?></strong>

Add the following line right after that:

    <?php if ($_item->getQtyBackordered()): ?>

        <p style="font-size: 10px;color: #CCC">
   * This product is not available  in the requested quantity. <?php echo  
   $_item->getQtyBackordered()*1 ?> of the items will be backordered.</p>

    <?php endif; ?>

qty_backordered set to NULL means your item was in stock in requested quantity by the moment of order was placed.

Other result means you have a problem with your installation. I'd suggest disabling 3rd party extensions to test if the problem is off-core.

  • Ok thanks, I will disable all extension and do a test order to check what's going on.
    – Akif
    Commented Jul 14, 2014 at 11:44

Something like this ?

$items = $order->getItems();

$hasBackorderedItems = false;
foreach($items as $item){ // loop though all items in order checking the backorder qty
     if($item->getQtyBackordered() > 0){
        $hasBackorderedItems = true; // order has back order item stop loop

This is not the most efficient way

  • Normally this would be sufficient. But the problem is the field QtyBackordered is allways NULL and has no value.
    – Akif
    Commented Jul 8, 2014 at 9:52
  • If the field is NULL then it means that there are no items on backorder. If the value is always null I'd check your stock settings to make sure the stock is being managed by Magento. Commented Jul 8, 2014 at 23:22
  • Yes, the value is always null. No matter if it has backorder items or not. The stock is managed. I think there is a bug somewhere why Magento doesn't write to the field. Do you have any clue in which file it writes to this field?
    – Akif
    Commented Jul 10, 2014 at 14:29

We just ran into the same problem as the topic starter. But we work with configurable products, and I just figured out the qty_backordered field is set to the child order_item (simples) only. The problem is that in the emails the items displayed are the parent order_items (configurables) which have indeed the qty_backordered set to NULL.

So we fixed this as follows in the email template:

    $itemQtyBackordered = intval($_item->getQtyBackordered());
    $childQtyBackordered = 0;

    if ($itemQtyBackordered === 0) // if no qty backordered found on item, check if the child item has it
        $childOrderItems = Mage::getModel('sales/order_item')->getCollection()->addAttributeToFilter('parent_item_id', array('eq' => $_item->getItemId()));
        if ($childOrderItems->count() > 0)
            $child = $childOrderItems->getFirstItem();
            $childQtyBackordered = intval($child->getQtyBackordered());

<?php if ($itemQtyBackordered > 0 || $childQtyBackordered > 0): ?>
    <p>your message</p>
<?php endif; ?>

If using Magento 2 (tested on 2.4.3): copy below file




After <p class="sku"><?= $block->escapeHtml(__('SKU')) ?>: <?= $block->escapeHtml($block->getSku($_item)) ?></p>

Add below code:

<?php if ($_item->getQtyBackordered()): ?>
        <p style="font-size: 12px;">Please note that requested quantity is not in stock, this item has
            been bckordered.</p>

    <?php elseif ($_item->getHasChildren()):
        foreach ($_item->getChildrenItems() as $child) {
            if ($child->getQtyBackordered()) { ?>
                <p style="font-size: 12px;">Please note that requested quantity is not in stock, this
                    item has been bckordered.</p>
            <?php }

This code works with simple products and configurable products. It should work with Grouped products as well but not been tested.

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.