Magento – Get Product Image on Success Page

checkoutonepage-checkoutorder-grid

On the success page after the order is displayed, I want to display a summary.
For this I use this code.

I want to display the product image also. How can I achieve that?

And how do I display the summary, with tax and grand total?

<?php 
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId(); 
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id); 
$shipping_address_data = $order_details->getShippingAddress();
?>
            <table>
             <tr> 
                <th><?php echo $this->__('Description') ?></th
                <th><?php echo $this->__('Description') ?></th>
                <th><?php echo $this->__('Qty') ?></th>
                <th><?php echo $this->__('Unit Price') ?></th>
            </tr>

        <?php foreach($order_details->getAllVisibleItems() as $item): ?> 
            <tr>
                <td><?php echo $item->getSmallImageUrl(); ?></td>
                <td><?php echo $item->getName() ?></td>
                <td><?php echo round($item->getQtyOrdered(), 0) ?></td>
                <td><?php echo Mage::helper("core")->currency($item->getPrice()) ?></td>
            </tr>
            </table>
        <?php endforeach ?> 

        <?php echo "<br>" . $shipping_address_data['country_name']; ?>

Best Answer

Try the below code it will works fine.

<?php 
    $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId(); 
    $order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id); 
    $shipping_address_data = $order_details->getShippingAddress();
    ?>
                <table>
                 <tr> 
                    <th><?php echo $this->__('Description') ?></th
                    <th><?php echo $this->__('Description') ?></th>
                    <th><?php echo $this->__('Qty') ?></th>
                    <th><?php echo $this->__('Unit Price') ?></th>
                </tr>

            <?php foreach($order_details->getAllVisibleItems() as $item): 
    $configItem = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
    ?> 
                <tr>
                    <td><img src="<?php echo $this->helper('catalog/image')->init($configItem, 'small_image')->resize(200); ?>" width="200" height="200" class="media-object img-responsive" alt="<?php echo $this->getImageLabel($configItem, 'small_image'); ?>"/></td>
                    <td><?php echo $item->getName() ?></td>
                    <td><?php echo round($item->getQtyOrdered(), 0) ?></td>
                    <td><?php echo Mage::helper("core")->currency($item->getPrice()) ?></td>
                </tr>
                </table>
            <?php endforeach ?> 

            <?php echo "<br>" . $shipping_address_data['country_name']; ?>