简体   繁体   English

如何在Magento中显示发票编号和日期?

[英]How to show invoice no and date in Magento?

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 "&nbsp".$this->gettotalamount(); ?><br>
    <b>Payment Type:</b> <?php echo $_order->getPayment()->getMethodInstance()->getTitle(); ?>

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. 根据您的代码,您已经在$_order上加载了订单模型,因此请尝试以下代码。

<?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 dmy format (answer of your question which is in comments) 以dmy格式获取日期(您的问题的答案在注释中)

<?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;
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM