Public Member Functions | |
preDispatch () | |
historyAction () | |
viewAction () | |
viewOldAction () | |
invoiceAction () | |
shipmentAction () | |
creditmemoAction () | |
reorderAction () | |
printAction () | |
printInvoiceAction () | |
printShipmentAction () | |
printCreditmemoAction () | |
Protected Member Functions | |
_canViewOrder ($order) | |
_viewAction () | |
_loadValidOrder ($orderId=null) | |
_canViewOscommerceOrder ($order) |
Definition at line 35 of file OrderController.php.
_canViewOrder | ( | $ | order | ) | [protected] |
Check order view availability
Mage_Sales_Model_Order | $order |
Definition at line 76 of file OrderController.php.
00077 { 00078 $customerId = Mage::getSingleton('customer/session')->getCustomerId(); 00079 $availableStates = Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates(); 00080 if ($order->getId() && $order->getCustomerId() && ($order->getCustomerId() == $customerId) 00081 && in_array($order->getState(), $availableStates, $strict = true) 00082 ) { 00083 return true; 00084 } 00085 return false; 00086 }
_canViewOscommerceOrder | ( | $ | order | ) | [protected] |
Check osCommerce order view availability
array | $order |
Definition at line 145 of file OrderController.php.
00146 { 00147 $customerId = Mage::getSingleton('customer/session')->getCustomerId(); 00148 if (isset($order['osc_magento_id']) && isset($order['magento_customers_id']) && $order['magento_customers_id'] == $customerId) { 00149 return true; 00150 } 00151 return false; 00152 }
_loadValidOrder | ( | $ | orderId = null |
) | [protected] |
Try to load valid order by order_id and register it
int | $orderId |
Definition at line 109 of file OrderController.php.
00110 { 00111 if (null === $orderId) { 00112 $orderId = (int) $this->getRequest()->getParam('order_id'); 00113 } 00114 if (!$orderId) { 00115 $this->_forward('noRoute'); 00116 return false; 00117 } 00118 00119 $order = Mage::getModel('sales/order')->load($orderId); 00120 00121 if ($this->_canViewOrder($order)) { 00122 Mage::register('current_order', $order); 00123 return true; 00124 } 00125 else { 00126 $this->_redirect('*/*/history'); 00127 } 00128 return false; 00129 }
_viewAction | ( | ) | [protected] |
Definition at line 88 of file OrderController.php.
00089 { 00090 if (!$this->_loadValidOrder()) { 00091 return; 00092 } 00093 00094 $this->loadLayout(); 00095 $this->_initLayoutMessages('catalog/session'); 00096 00097 if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) { 00098 $navigationBlock->setActive('sales/order/history'); 00099 } 00100 $this->renderLayout(); 00101 }
creditmemoAction | ( | ) |
historyAction | ( | ) |
Customer order history
Definition at line 57 of file OrderController.php.
00058 { 00059 $this->loadLayout(); 00060 $this->_initLayoutMessages('catalog/session'); 00061 00062 $this->getLayout()->getBlock('head')->setTitle($this->__('My Orders')); 00063 00064 if ($block = $this->getLayout()->getBlock('customer.account.link.back')) { 00065 $block->setRefererUrl($this->_getRefererUrl()); 00066 } 00067 $this->renderLayout(); 00068 }
invoiceAction | ( | ) |
preDispatch | ( | ) |
Action predispatch
Check customer authentication for some actions
Reimplemented from Mage_Core_Controller_Front_Action.
Definition at line 43 of file OrderController.php.
00044 { 00045 parent::preDispatch(); 00046 $action = $this->getRequest()->getActionName(); 00047 $loginUrl = Mage::helper('customer')->getLoginUrl(); 00048 00049 if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) { 00050 $this->setFlag('', self::FLAG_NO_DISPATCH, true); 00051 } 00052 }
printAction | ( | ) |
Definition at line 232 of file OrderController.php.
00233 { 00234 if (!$this->_loadValidOrder()) { 00235 return; 00236 } 00237 $this->loadLayout('print'); 00238 $this->renderLayout(); 00239 }
printCreditmemoAction | ( | ) |
Definition at line 286 of file OrderController.php.
00287 { 00288 $creditmemoId = (int) $this->getRequest()->getParam('creditmemo_id'); 00289 if ($creditmemoId) { 00290 $creditmemo = Mage::getModel('sales/order_creditmemo')->load($creditmemoId); 00291 $order = $creditmemo->getOrder(); 00292 } else { 00293 $orderId = (int) $this->getRequest()->getParam('order_id'); 00294 $order = Mage::getModel('sales/order')->load($orderId); 00295 } 00296 00297 if ($this->_canViewOrder($order)) { 00298 Mage::register('current_order', $order); 00299 if (isset($creditmemo)) { 00300 Mage::register('current_creditmemo', $creditmemo); 00301 } 00302 $this->loadLayout('print'); 00303 $this->renderLayout(); 00304 } else { 00305 $this->_redirect('*/*/history'); 00306 } 00307 }
printInvoiceAction | ( | ) |
Definition at line 241 of file OrderController.php.
00242 { 00243 $invoiceId = (int) $this->getRequest()->getParam('invoice_id'); 00244 if ($invoiceId) { 00245 $invoice = Mage::getModel('sales/order_invoice')->load($invoiceId); 00246 $order = $invoice->getOrder(); 00247 } else { 00248 $orderId = (int) $this->getRequest()->getParam('order_id'); 00249 $order = Mage::getModel('sales/order')->load($orderId); 00250 } 00251 00252 if ($this->_canViewOrder($order)) { 00253 Mage::register('current_order', $order); 00254 if (isset($invoice)) { 00255 Mage::register('current_invoice', $invoice); 00256 } 00257 $this->loadLayout('print'); 00258 $this->renderLayout(); 00259 } else { 00260 $this->_redirect('*/*/history'); 00261 } 00262 }
printShipmentAction | ( | ) |
Definition at line 264 of file OrderController.php.
00265 { 00266 $shipmentId = (int) $this->getRequest()->getParam('shipment_id'); 00267 if ($shipmentId) { 00268 $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId); 00269 $order = $shipment->getOrder(); 00270 } else { 00271 $orderId = (int) $this->getRequest()->getParam('order_id'); 00272 $order = Mage::getModel('sales/order')->load($orderId); 00273 } 00274 if ($this->_canViewOrder($order)) { 00275 Mage::register('current_order', $order); 00276 if (isset($shipment)) { 00277 Mage::register('current_shipment', $shipment); 00278 } 00279 $this->loadLayout('print'); 00280 $this->renderLayout(); 00281 } else { 00282 $this->_redirect('*/*/history'); 00283 } 00284 }
reorderAction | ( | ) |
Definition at line 197 of file OrderController.php.
00198 { 00199 if (!$this->_loadValidOrder()) { 00200 return; 00201 } 00202 $order = Mage::registry('current_order'); 00203 00204 $cart = Mage::getSingleton('checkout/cart'); 00205 $cartTruncated = false; 00206 /* @var $cart Mage_Checkout_Model_Cart */ 00207 00208 $items = $order->getItemsCollection(); 00209 foreach ($items as $item) { 00210 try { 00211 $cart->addOrderItem($item); 00212 } catch (Mage_Core_Exception $e){ 00213 if (Mage::getSingleton('checkout/session')->getUseNotice(true)) { 00214 Mage::getSingleton('checkout/session')->addNotice($e->getMessage()); 00215 } 00216 else { 00217 Mage::getSingleton('checkout/session')->addError($e->getMessage()); 00218 } 00219 $this->_redirect('*/*/history'); 00220 } catch (Exception $e) { 00221 Mage::getSingleton('checkout/session')->addException($e, 00222 Mage::helper('checkout')->__('Can not add item to shopping cart') 00223 ); 00224 $this->_redirect('checkout/cart'); 00225 } 00226 } 00227 00228 $cart->save(); 00229 $this->_redirect('checkout/cart'); 00230 }
shipmentAction | ( | ) |
viewAction | ( | ) |
Order view page
Definition at line 134 of file OrderController.php.
00135 { 00136 $this->_viewAction(); 00137 }
viewOldAction | ( | ) |
osCommerce Order view page
Definition at line 157 of file OrderController.php.
00158 { 00159 00160 $orderId = (int) $this->getRequest()->getParam('order_id'); 00161 if (!$orderId) { 00162 $this->_forward('noRoute'); 00163 return; 00164 } 00165 00166 $order = Mage::getModel('oscommerce/oscommerce')->loadOrderById($orderId); 00167 if ($this->_canViewOscommerceOrder($order['order'])) { 00168 Mage::register('current_oscommerce_order', $order); 00169 $this->loadLayout(); 00170 if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) { 00171 $navigationBlock->setActive('sales/order/history'); 00172 } 00173 00174 $this->renderLayout(); 00175 } 00176 else { 00177 $this->_redirect('*/*/history'); 00178 } 00179 00180 }