【问题标题】:How to show invoice no and date in Magento?如何在 Magento 中显示发票编号和日期?
【发布时间】:2015-09-29 12:12:12
【问题描述】:

我正在使用一个页面来显示订单详细信息,并希望在该页面中显示发票编号和日期。请告诉我如何显示发票编号。这是代码:

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

【问题讨论】:

  • 请编辑您的问题。您的代码不可见
  • 代码已编辑检查
  • 帮帮我,请给我解决方案。

标签: php magento invoice


【解决方案1】:

下面是获取与任何订单相关的发票信息的代码 sn-p。根据你的代码,你已经在$_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()));
     }
}
?>

以 d-m-y 格式获取日期(您的问题的答案在 cmets 中)

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

【讨论】:

  • 有任何方法可以在不输入特定订单 ID 的情况下显示订单编号。它将自动加载发票号。通过自动获取订单 ID。上面使用的是哪个订单 ID。
  • 表示我不想添加订单号。我想自动加载订单号,它会显示 ivoice no 并且在发票日期我只想显示日期而不是时间。并想显示发票号。像这样不在数组中,也不在任何括号中。只想显示订单日期而不是时间和订单日期格式将是 d/m/y 提前谢谢。因为我用它来创建零售发票想在这段代码中自动加载订单号。
  • 更新了我的答案。请检查。
  • 我认为您缺少 php 标签,这就是为什么所有代码​​都以 html 形式出现的原因。
  • 我收到此错误调用 /home/s250 中非对象上的成员函数 getMethodInstance()
猜你喜欢
  • 2015-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-11
  • 1970-01-01
  • 2021-05-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多