Reputation: 37
I am using a page to display order details and want to show invoice no and date in that page. Please tell me how to show invoice no. Here is the code:
<div class="col-sm-4 invoice-`co`l">
<b>Order No. </b>#
<?php if ($this->getNoUseOrderLink()): ?>
<?php echo $_order->getRealOrderId(); ?>
<?php else: ?>
<?php echo $_order->getRealOrderId(); ?>
<?php endif; ?>
<br>
<b>Amount:</b> <?php echo " ".$this->gettotalamount(); ?><br>
<b>Payment Type:</b> <?php echo $_order->getPayment()->getMethodInstance()->getTitle(); ?>
Upvotes: 1
Views: 1677
Reputation: 815
Below is the code snippet to get Invoice info associated with any order. Based on your code, you have already loaded order model on $_order
, so try below code.
<?php
// ignore below two lines if you already have order model
// $_order=Mage::getModel('sales/order')->loadByIncrementId($anyorderincrementid);
// $_order=Mage::getModel('sales/order')->load($anyorderentityid);
if ($_order->hasInvoices()) {
$invIncrementIDs = array();
foreach ($_order->getInvoiceCollection() as $inv) {
echo "Invoice Id- ".$inv->getIncrementId();
echo "Invoice Date- ".date('d-m-Y',strtotime($inv->getCreatedAt()));
}
}
?>
To get date in d-m-y format (answer of your question which is in comments)
<?php
// format admin and store date
$orderAdminDate=date('d-m-y',strtotime($orderAdminDate));
$orderStoreDate=date('d-m-y',strtotime($orderStoreDate));
echo $orderAdminDate;
if ($orderAdminDate != $orderStoreDate):
echo date('d-m-y',strtotime($_order->getCreatedAtStoreDate()));
echo $orderStoreDate;
endif;
?>
Upvotes: 1