本文整理汇总了PHP中Mage_Sales_Model_Order::getInvoiceCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order::getInvoiceCollection方法的具体用法?PHP Mage_Sales_Model_Order::getInvoiceCollection怎么用?PHP Mage_Sales_Model_Order::getInvoiceCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order::getInvoiceCollection方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getInvoiceForTransactionId
/**
* Return invoice model for transaction
*
* @param Mage_Sales_Model_Order $order
* @param string $transactionId
* @return Mage_Sales_Model_Order_Invoice
*/
protected function _getInvoiceForTransactionId($order, $transactionId)
{
foreach ($order->getInvoiceCollection() as $invoice) {
if ($invoice->getTransactionId() == $transactionId) {
return $invoice;
}
}
foreach ($order->getInvoiceCollection() as $invoice) {
if ($invoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_OPEN) {
$invoice->setTransactionId($transactionId);
return $invoice;
}
}
return false;
}
示例2: prepareInvoice
/**
* Prepare order invoice based on order data and requested items qtys. If $qtys is not empty - the function will
* prepare only specified items, otherwise all containing in the order.
*
* @param array $qtys
* @return Mage_Sales_Model_Order_Invoice
*/
public function prepareInvoice($qtys = array())
{
$invoice = $this->_convertor->toInvoice($this->_order);
$totalQty = 0;
foreach ($this->_order->getAllItems() as $orderItem) {
if (!$this->_canInvoiceItem($orderItem, array())) {
continue;
}
$item = $this->_convertor->itemToInvoiceItem($orderItem);
if ($orderItem->isDummy()) {
$qty = $orderItem->getQtyOrdered() ? $orderItem->getQtyOrdered() : 1;
} else {
if (!empty($qtys)) {
if (isset($qtys[$orderItem->getId()])) {
$qty = (double) $qtys[$orderItem->getId()];
}
} else {
$qty = $orderItem->getQtyToInvoice();
}
}
$totalQty += $qty;
$item->setQty($qty);
$invoice->addItem($item);
}
$invoice->setTotalQty($totalQty);
$invoice->collectTotals();
$this->_order->getInvoiceCollection()->addItem($invoice);
return $invoice;
}
示例3: _processInvoicedCreditMemos
/**
*
*/
protected function _processInvoicedCreditMemos()
{
foreach ($this->_order->getInvoiceCollection() as $invoice) {
if ($invoice->canRefund()) {
$this->_processInvoicedCreditMemo($invoice);
}
}
}
示例4: _saveInvoice
/**
* Saves an invoice and sets total-paid for the order
*
* @return bool
*/
protected function _saveInvoice()
{
if ($this->_order->canInvoice() && !$this->_order->hasInvoices()) {
$payment = $this->_order->getPayment();
$payment->registerCaptureNotification($this->_order->getBaseGrandTotal());
$this->_order->save();
$this->_debugEmail .= 'Invoice created and saved. \\n';
//sets the invoice's transaction ID as the Buckaroo TRX. This is to allow the order to be refunded using Buckaroo later on.
foreach ($this->_order->getInvoiceCollection() as $invoice) {
if (!isset($this->_postArray['brq_transactions'])) {
continue;
}
$invoice->setTransactionId($this->_postArray['brq_transactions'])->save();
}
return true;
}
return false;
}
示例5: deleteOrder
public function deleteOrder(Mage_Sales_Model_Order $order)
{
$invoices = $order->getInvoiceCollection();
foreach ($invoices as $invoice) {
//delete all invoice items
$items = $invoice->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete invoice
$invoice->delete();
}
$creditnotes = $order->getCreditmemosCollection();
foreach ($creditnotes as $creditnote) {
//delete all creditnote items
$items = $creditnote->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete credit note
$creditnote->delete();
}
$shipments = $order->getShipmentsCollection();
foreach ($shipments as $shipment) {
//delete all shipment items
$items = $shipment->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete shipment
$shipment->delete();
}
//delete all order items
$items = $order->getAllItems();
foreach ($items as $item) {
$item->delete();
}
//delete payment - not sure about this one
$order->getPayment()->delete();
//delete quote - this can be skipped
/*if ($order->getQuote()) {
foreach ($order->getQuote()->getAllItems() as $item) {
$item->delete();
}
$order->getQuote()->delete();
}*/
//delete order
$order->delete();
return $this;
}
示例6: invoice
public function invoice(Mage_Sales_Model_Order $order, $transactionId, $mail)
{
if ($order->canInvoice()) {
$invoice = $order->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->register();
Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
$invoice->setTransactionId($transactionId);
$invoice->pay();
$invoice->save();
$invoice->sendEmail($mail, '');
} else {
foreach ($order->getInvoiceCollection() as $invoice) {
$invoice->pay()->save();
}
}
}
示例7: _hasInvoices
/**
* @param Mage_Sales_Model_Order $order
*
* @return bool
*/
protected function _hasInvoices(Mage_Sales_Model_Order $order)
{
/** @var Mage_Sales_Model_Resource_Order_Invoice_Collection $invoices */
$invoices = $order->getInvoiceCollection();
if ($invoices->getSize() > 0) {
return true;
}
return false;
}
示例8: _getOrderInvoice
/**
* Return invoice model for current order
*
* @param Mage_Sales_Model_Order $order
* @return Mage_Sales_Model_Order_Invoice
*/
protected function _getOrderInvoice($order)
{
foreach ($order->getInvoiceCollection() as $orderInvoice) {
if ($orderInvoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_PAID || $orderInvoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_OPEN) {
return $orderInvoice;
}
}
return false;
}
示例9: getAllInvoiceItems
/**
* Retrieve all invoice items from the given order
*
* @param Mage_Sales_Model_Order $order
* @return array
*/
public function getAllInvoiceItems(Mage_Sales_Model_Order $order)
{
$invoices = $order->getInvoiceCollection();
$invoiceItems = array();
foreach ($invoices as $invoice) {
foreach (Mage::helper('ratepaypayment/mapping')->getArticles($invoice) as $article) {
$article['articleNumber'] == 'DISCOUNT' ? $condition = $article['articleName'] : ($condition = $article['articleNumber']);
if (array_key_exists($condition, $invoiceItems)) {
$invoiceItems[$condition]['quantity'] += $article['quantity'];
$invoiceItems[$condition]['totalPrice'] += $article['totalPrice'];
$invoiceItems[$condition]['unitPriceGross'] += $article['unitPriceGross'];
$invoiceItems[$condition]['tax'] += $article['tax'];
$invoiceItems[$condition]['taxPercent'] = $article['taxPercent'];
} else {
$invoiceItems[$condition]['quantity'] = $article['quantity'];
$invoiceItems[$condition]['unitPrice'] = $article['unitPrice'];
$invoiceItems[$condition]['unitPriceGross'] = $article['unitPriceGross'];
$invoiceItems[$condition]['totalPrice'] = $article['totalPrice'];
$invoiceItems[$condition]['tax'] = $article['tax'];
$invoiceItems[$condition]['taxPercent'] = $article['taxPercent'];
$invoiceItems[$condition]['articleNumber'] = $article['articleNumber'];
$invoiceItems[$condition]['articleName'] = $article['articleName'];
$invoiceItems[$condition]['discountId'] = $article['discountId'];
}
}
}
return $invoiceItems;
}
示例10: createCreditmemo
protected function createCreditmemo(Mage_Sales_Model_Order $order, $data)
{
$invoices = $order->getInvoiceCollection();
if ($invoices->count() == 1) {
$invoice = $invoices->getFirstItem();
}
if (!$invoice->getId()) {
throw new Exception('Invoice could not be loaded.');
}
if (!$order->canCreditmemo()) {
throw new Exception('Creditmemo cannot be created for order.');
}
if ($data['shipping_amount'] == 'all') {
$data['shipping_amount'] = $invoice->getShippingAmount();
}
$service = Mage::getModel('sales/service_order', $order);
$creditmemo = $service->prepareInvoiceCreditmemo($invoice, $data);
foreach ($creditmemo->getAllItems() as $creditmemoItem) {
$orderItem = $creditmemoItem->getOrderItem();
$parentId = $orderItem->getParentItemId();
$creditmemoItem->setBackToStock(true);
}
if ($creditmemo) {
if ($creditmemo->getGrandTotal() <= 0 && !$creditmemo->getAllowZeroGrandTotal()) {
Mage::throwException(Mage::helper('SaferpayCw')->__("Credit memo's total must be positive."));
}
Mage::register('cw_saferpaycw_refund_update', true);
$creditmemo->setRefundRequested(true);
$creditmemo->register();
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($creditmemo)->addObject($creditmemo->getOrder());
if ($creditmemo->getInvoice()) {
$transactionSave->addObject($creditmemo->getInvoice());
}
$transactionSave->save();
}
}
示例11: setInvoicesToPaid
/**
* sets the invoices of an order to paid
*
* @param Mage_Sales_Model_Order $order
* @return Netresearch_OPS_Helper_Payment
*/
public function setInvoicesToPaid($order)
{
/** @var $invoice Mage_Sales_Model_Order_Invoice */
foreach ($order->getInvoiceCollection() as $invoice) {
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
$invoice->save();
}
return $this;
}
示例12: setOrderState
/**
* Set an order status based on transaction status
*
* @param Mage_Sales_Model_Order $order
* @param string $status
* @param string $message
*/
public function setOrderState($order, $status, $message = '')
{
$this->initLibrary();
switch ($status) {
case \Genesis\API\Constants\Transaction\States::APPROVED:
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, $message, false)->save();
break;
case \Genesis\API\Constants\Transaction\States::PENDING:
case \Genesis\API\Constants\Transaction\States::PENDING_ASYNC:
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, $message, false)->save();
break;
case \Genesis\API\Constants\Transaction\States::ERROR:
case \Genesis\API\Constants\Transaction\States::DECLINED:
/** @var Mage_Sales_Model_Order_Invoice $invoice */
foreach ($order->getInvoiceCollection() as $invoice) {
$invoice->cancel();
}
$order->registerCancellation($message)->setCustomerNoteNotify(true)->save();
break;
default:
$order->save();
break;
}
}
示例13: _processDirectSale
/**
* Process Configured Payment Action: Direct Sale, create invoce if state is Pending
*
* @param Mage_Sales_Model_Order $order Order
* @param array $params Request params
*/
protected function _processDirectSale($order, $params, $instantCapture = 0)
{
Mage::register('postfinance_auto_capture', true);
$status = $params['STATUS'];
if ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AWAIT_CUSTOMER_PAYMENT) {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('postfinance')->__('Waiting for the payment of the customer'));
$order->save();
} elseif ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AUTHORIZED_WAITING) {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('postfinance')->__('Authorization waiting from PostFinance'));
$order->save();
} elseif ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT || $instantCapture) {
if ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AUTHORIZED) {
if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('postfinance')->__('Processed by PostFinance'));
}
} else {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('postfinance')->__('Processed by PostFinance'));
}
if (!$order->getInvoiceCollection()->getSize()) {
$invoice = $order->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->register();
$invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
$invoice->getOrder()->setIsInProcess(true);
$invoice->save();
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
/*
* If the payment method is a redirect-payment-method send the email
* In any other case Magento sends an email automatically in Mage_Checkout_Model_Type_Onepage::saveOrder
*/
if ($this->isRedirectPaymentMethod($order) === true && $order->getEmailSent() !== '1') {
$order->sendNewOrderEmail();
}
}
} else {
$order->save();
}
}
示例14: _convertConfigTags
/**
* @param array $tagsConfig
* @param Mage_Sales_Model_Order $order
*
* @return bool|array
*/
protected function _convertConfigTags($tagsConfig = array(), Mage_Sales_Model_Order $order = null)
{
if (empty($tagsConfig) || empty($order) || !$order->getId()) {
return false;
}
$tags = array();
foreach ($tagsConfig as $key => $config) {
/** @var $config Varien_Object */
$object = $config->getData('object');
switch ($object) {
case 'payment':
/** @var Mage_Sales_Model_Order_Payment $object */
$object = $order->getPayment();
break;
case 'invoice':
/**
* @var Mage_Sales_Model_Resource_Order_Invoice_Collection $invoices
* @var Mage_Sales_Model_Order_Invoice $object
*/
$invoices = $order->getInvoiceCollection();
$object = $invoices->getFirstItem();
break;
case 'shipping_address':
/** @var Mage_Sales_Model_Order_Address $object */
$object = $order->getShippingAddress();
break;
case 'shipment':
/**
* @var Mage_Sales_Model_Resource_Order_Shipment_Collection $shipments
* @var Mage_Sales_Model_Order_Shipment $object
*/
$shipments = $order->getShipmentsCollection();
$object = $shipments->getFirstItem();
break;
case 'order':
default:
$object = $order;
break;
}
if (!$object || !$object->getId()) {
continue;
}
$dataKey = $config->getData('data');
$data = $this->_extractTagData($dataKey, $config, $object);
switch ($config->getData('type')) {
case 'int':
$data = (int) $data;
break;
case 'float':
$data = (double) $data;
break;
case 'double':
$data = (double) $data;
break;
case 'date':
/** @var Mage_Core_Model_Date $date */
$date = Mage::getModel('core/date');
$data = $date->date('d/m/Y H:i:s', strtotime($data));
break;
case 'currency':
$data = (string) $this->_helper()->formatCurrency((double) $data, false);
break;
case 'string':
default:
$data = (string) $data;
break;
}
$label = $config->getData('alias');
if (empty($label)) {
$label = $config->getData('label');
}
$label = $this->__($label);
$tags[$label] = $data;
}
return $tags;
}