簡體   English   中英

如何在Magento中顯示發票編號和日期?

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

我正在使用一個頁面來顯示訂單詳細信息,並希望在該頁面中顯示發票編號和日期。 請告訴我如何顯示發票編號。 這是代碼:

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

以下是獲取與任何訂單關聯的發票信息的代碼段。 根據您的代碼,您已經在$_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()));
     }
}
?>

以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