如何在magento中给出$ payment对象的发票ID

时间:2014-03-31 18:20:54

标签: magento payment invoice

在Magento中有这个功能:

public function capture(Varien_Object $payment, $amount)
{
      $order = $payment->getOrder();
      $order_id = $order->getId();

      $invoice = ????
      $invoice_id = $invoice->getId();
}

如何获取发票或发票ID?

1 个答案:

答案 0 :(得分:1)

Mage_Sales_Model_Order包含hasInvoices()getInvoiceCollection()等方法:

public function capture(Varien_Object $payment, $amount)
{
      $order = $payment->getOrder();
      $order_id = $order->getId();

      if ($order->hasInvoices()) {
          $oInvoiceCollection = $order->getInvoiceCollection();
          foreach ($oInvoiceCollection as $oInvoice) {
              $invoice_id = $oInvoice->getId();
              // ...
          }
      }

}