3

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']; ?>
4

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']; ?>
  • Many thanks! :) And do you know how to display the summary with tax and grand total? – Henk Z Apr 9 '15 at 11:11
1

jello,for getting the product to you load product Model by item product id,as magento sales model does not save image url on sales_flat_item table at Database

$product=Mage::getModel('catalog/product')->load($item->getProductId());
if($product->getId()):
echo $product->getSmallImageUrl();
endif;
1

Below code snippet is working well for me on success.phtml

$_product = Mage::getModel('catalog/product')->load($item->getProductId());
         $product_small_image_path = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(135);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.