How to add the backorder field with data in salesorder page .

 Before this we need to create fileds using installschema to create inthe sales_order table.after that for fetching the data we need to create a block.
this code is can use in magneto_sales in templates file which is display frontend view.phtml .it is only visible for qty column of sales order page.
<?php $backorderQty = (int)$item->getQtyBackordered(); ?>
        <?php $backorderTotal = $item->getBackorderTotal(); ?>

<td data-th="<?= $block->escapeHtml(__('Qty')) ?>" class="col qty">
                <span class="ordered-qty"><?= __('Ordered Qty: %1', (int)$item->getQtyOrdered()) ?></span>
                 <?php if ($backorderQty >= 0) : ?>
                    <br> 
                     <span class="qty_backordered"><?= __('Backorder Qty: %1', (int)$item->getQtyBackordered()) ?></span> 
                    <br>
                    <span class="backorder-total"><?= __('Backorder Total: %1', $backorderTotal) ?></span>
                <?php endif; ?>
            </td>

Leave a comment

Your email address will not be published. Required fields are marked *