/** * @since 0.0.2 * @param unknown_type $order */ protected function _paymentMethodCode($order) { return $order->getPayment()->getMethod(); }
/** * Retourne sous la forme de texte les détails pour une commande * * @param unknown_type $order */ public function getDetailsForOrder($order, $ShowInvoiceShipment = true) { //gernere la chaine et retourne $retour = ''; $retour .= '' . mage::helper('Orderpreparation')->__('Total') . ': ' . number_format($order->getgrand_total(), 2); $retour .= "<br>Date: " . mage::helper('core')->formatDate($order->getcreated_at(), 'long'); //Définit l'etat du paiement $retour .= "<br>" . mage::helper('Orderpreparation')->__('Payment') . ": "; if ($order->getpayment_validated() == 1) { $retour .= '<font color="green">' . mage::helper('Orderpreparation')->__('Yes') . '</font>'; } else { $retour .= '<font color="red">' . mage::helper('Orderpreparation')->__('No') . '</font>'; } $retour .= "<br>" . mage::helper('Orderpreparation')->__('Status') . ": " . $order->getstatus(); $retour .= "<br>" . mage::helper('Orderpreparation')->__('Carrier') . ": " . $order->getshipping_description(); if ($order->getPayment()) { $retour .= "<br>" . mage::helper('Orderpreparation')->__('Payment') . ": " . $order->getPayment()->getMethodInstance()->gettitle(); } if ($ShowInvoiceShipment) { $OrderToPrepare = mage::getModel('Orderpreparation/ordertoprepare')->load($order->getId(), 'order_id'); if ($OrderToPrepare) { $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($OrderToPrepare->getinvoice_id()); $shipment = Mage::getModel('sales/order_shipment')->loadByIncrementId($OrderToPrepare->getshipment_id()); if ($OrderToPrepare->getinvoice_id() != '') { $retour .= '<br>' . mage::helper('Orderpreparation')->__('Invoice') . ': <a target="_new" href="' . Mage::helper('adminhtml')->getUrl('adminhtml/sales_order_invoice/print', array('invoice_id' => $invoice->getId())) . '"> ' . $OrderToPrepare->getinvoice_id() . '</a>'; } if ($OrderToPrepare->getshipment_id()) { $retour .= '<br>' . mage::helper('Orderpreparation')->__('Shipment') . ': <a target="_new" href="' . Mage::helper('adminhtml')->getUrl('adminhtml/sales_order_shipment/print', array('invoice_id' => $shipment->getId())) . '"> ' . $OrderToPrepare->getshipment_id() . '</a>'; } } //Rajoute les no de tracking $tracking_txt = ''; foreach ($order->getTracksCollection() as $track) { $obj = $track->getNumberDetail(); if (is_object($obj)) { $tracking_txt .= $track->getNumberDetail()->gettracking() . '<br>'; } else { if (is_array($obj)) { $tracking_txt .= $obj["number"] . '<br>'; } else { $tracking_txt .= $obj . '<br>'; } } } if ($tracking_txt != '') { $retour .= "<br>Tracking: " . $tracking_txt; } } return $retour; }
/** * Set the invoice status to "Paid" after a successful payment * * @param unknown_type $order */ private function _updateInvoices($order, $message) { $invoices = $order->getInvoiceCollection(); $state = Mage_Sales_Model_Order::STATE_PROCESSING; $payment = $order->getPayment(); $transaction; $session = Mage::getSingleton('checkout/session'); $szNewCrossReference; $transactionId = $payment->getLastTransId(); $transaction = $payment->getTransaction($transactionId); $transactionType = $transaction->getTxnType(); if ($session->getNewCrossReference()) { $szNewCrossReference = $session->getNewCrossReference(); $value = $transaction->setTxnId($szNewCrossReference); $transaction->save(); $payment->setLastTransId($szNewCrossReference); $session->setNewCrossReference(null); } foreach ($invoices as $invoice) { // set the invoice state to be "Paid" $invoice->pay()->save(); } // add a comment to the order comments if ($transactionType == 'authorization') { $order->setState($state, 'csv_preauth', $message, true); } else { if ($transactionType == 'capture') { $order->setState($state, 'csv_paid', $message, true); } else { Mage::throwException('invalid transaction type [' . $transactionType . '] for invoice updating'); } } $order->save(); }