Friday 20 September 2013

Get Order Details On Order Success-page

put the below code in frontend/default/default/template/checkout/success.phtml

<?php /* order detail on success page code starts here:- */ ?>
<?php $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
 $order_items = $order->getAllItems();
?>
<div class="success-box">
  <div class="successorderleft">
    <div class="content">
      <h4><?php echo $this->__('Your Confirmation Number is:') ?></h4>
      <p><?php echo $this->getOrderId();?></p>
      <p>Order Date: <?php echo  $this->formatDate($order->getCreatedAt(),'long') ;?></p>
    </div>
    <?php if($order->_data["shipping_description"]!=''){ ?>
    <div class="content">
      <h4><?php echo $this->__('Your Delivery type is:') ?></h4>
      <p><?php echo $shipping_method = $order->_data["shipping_description"];  ?></p>
    </div>
    <?php } ?>
    <div class="content">
      <h4><?php echo $this->__('And we&rsquo;ll deliver to:') ?></h4>
      <p><?php echo $order->getShippingAddress()->getFormated(true); ?></p>
    </div>
  </div>
  <div class="Successright">
    <div class="order-details-head"><?php echo $this->__('You Ordered:') ?></div>
    <table border="0" cellspacing="0" cellpadding="0" class="data-table">
      <thead>
        <tr class="first last">
          <th class="first" colspan="1"><?php echo $this->__('Product Name') ?></th>
          <th class="a-center" style="width:48px;"><?php echo $this->__('QTY') ?></th>
          <th class="a-right" style="width:102px;"><?php echo $this->__('Unit Price') ?></th>
        </tr>
      </thead>
      <tbody>
        <?php foreach($order_items as $_item):
        if ($_item->getParentItem()) continue;
       
        $product = Mage::getModel("catalog/product")->getIdBySku($_item->getSku());
        $product = Mage::getModel("catalog/product")->load($product);
    ?>
        <tr class="odd a-letf">
          <td><h2 class="product-name"><a href="<?php echo $product->getProductUrl() ?>">
              <?php  echo $this->htmlEscape($product->getName());?>
              </a> </h2>
            <?php
          if($_options = $_item->getProductOptions()):?>
            <dl class="item-options">
              <?php foreach ($_options['attributes_info'] as $_option) :  ?>
              <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
              <dd><?php echo $_option['value'] ?></dd>
              <?php endforeach; ?>
            </dl>
            <?php endif; ?></td>
          <td class="a-center" ><p class="Succqty"><?php echo abs($_item->getQtyOrdered()); ?></p></td>
          <td class="a-right" ><?php echo Mage::helper('checkout')->formatPrice($this->helper('checkout')->getSubtotalInclTax($_item)) ?></td>
        </tr>
        <?php endforeach; ?>
      </tbody>
    </table>
    <table cellpadding="0" cellspacing="0" background="0" class="Successtabletotal">
      <tr>
        <td colspan="2" class="a-right success-subtotal"><?php echo $this->__('Subtotal:'); ?></td>
        <td class="a-right success-subtotal" style="width:102px;"><?php echo Mage::helper('checkout')->formatPrice($order->getSubtotal());?></td>
      </tr>
      <?php if($order->getCouponCode()!=""){?>
      <tr>
        <td colspan="2" class="a-right success-subtotal"><?php echo $this->__('Discount('.$order->getCouponCode().')'); ?></td>
        <td class="a-right success-subtotal" style="width:102px;"><?php echo Mage::helper("core")->currency($order->discount_amount) ;?></td>
      </tr>
      <?php }?>
      <tr>
        <td colspan="2" class="a-right success-shipping"><?php echo $this->__('Shipping:'); ?></td>
        <td class="a-right success-shipping" style="width:102px;"><?php echo Mage::helper('checkout')->formatPrice($order->getShippingAmount());?></td>
      </tr>
      <tr>
        <td colspan="2" class="a-right success-tax"><?php echo $this->__('Tax:'); ?></td>
        <td class="a-right success-tax" style="width:102px;"><?php echo Mage::helper('checkout')->formatPrice($order->getTaxAmount());?></td>
      </tr>
      <tr>
        <td colspan="2" class="a-right success-total"><?php echo $this->__('Total:'); ?></td>
        <td class="a-right success-total" style="width:102px;"><?php echo Mage::helper('checkout')->formatPrice($order->getGrandTotal());?></td>
      </tr>
    </table>
  </div>
</div>
<?php /* order detail on success page code end here:- */ ?>