00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Shipping_TrackingController extends Mage_Core_Controller_Front_Action
00036 {
00037 public function ajaxAction()
00038 {
00039 if ($order = $this->_initOrder()) {
00040 $response = '';
00041 $tracks = $order->getTracksCollection();
00042
00043 $className = Mage::getConfig()->getBlockClassName('core/template');
00044 $block = new $className();
00045 $block->setType('core/template')
00046 ->setIsAnonymous(true)
00047 ->setTemplate('sales/order/trackinginfo.phtml');
00048
00049 foreach ($tracks as $track){
00050 $trackingInfo = $track->getNumberDetail();
00051 $block->setTrackingInfo($trackingInfo);
00052 $response .= $block->toHtml()."\n<br />";
00053 }
00054
00055 $this->getResponse()->setBody($response);
00056 }
00057 }
00058
00059 public function popupAction()
00060 {
00061 $this->loadLayout();
00062 $this->renderLayout();
00063 }
00064
00065
00066
00067
00068
00069
00070
00071 protected function _initOrder()
00072 {
00073 $id = $this->getRequest()->getParam('order_id');
00074
00075 $order = Mage::getModel('sales/order')->load($id);
00076 $customerId = Mage::getSingleton('customer/session')->getCustomerId();
00077
00078 if (!$order->getId() || !$customerId || $order->getCustomerId() != $customerId) {
00079 return false;
00080 }
00081 return $order;
00082 }
00083
00084 }