Overview

Namespaces

  • None
  • PHP

Classes

  • Eabi_DpdEE_Block_Adminhtml_Config_Form_Field_Country
  • Eabi_DpdEE_Block_Info_Payment
  • Eabi_DpdEE_Block_Invoice
  • Eabi_DpdEE_Block_Order_Courier
  • Eabi_DpdEE_Helper_Data
  • Eabi_DpdEE_Model_Api
  • Eabi_DpdEE_Model_Button_Courier
  • Eabi_DpdEE_Model_Config
  • Eabi_DpdEE_Model_Flat
  • Eabi_DpdEE_Model_Observer
  • Eabi_DpdEE_Model_Payment_Processor
  • Eabi_DpdEE_Model_Post
  • Eabi_DpdEE_Model_Source_Label_Position
  • Eabi_DpdEE_Model_Source_Service
  • Eabi_Livehandler_Adminhtml_LivehandlerController
  • Eabi_Livehandler_Adminhtml_RemoveController
  • Eabi_Livehandler_Block_Adminhtml_Config_Form_Field_Button
  • Eabi_Livehandler_Block_Adminhtml_Config_Form_Field_Remove
  • Eabi_Livehandler_Block_Email
  • Eabi_LiveHandler_Block_Footer
  • Eabi_Livehandler_Helper_Data
  • Eabi_Livehandler_Helper_Keypair
  • Eabi_Livehandler_IndexController
  • Eabi_Livehandler_Model_Abstract
  • Eabi_Livehandler_Model_Action_Abstract
  • Eabi_Livehandler_Model_Action_Postoffice_Print
  • Eabi_Livehandler_Model_Action_Postoffice_Send
  • Eabi_Livehandler_Model_Adminhtml_Gridmanager
  • Eabi_Livehandler_Model_Directory_Collection
  • Eabi_Livehandler_Model_Entry
  • Eabi_Livehandler_Model_File_Object
  • Eabi_Livehandler_Model_Mysql4_Entry
  • Eabi_Livehandler_Model_Mysql4_Entry_Collection
  • Eabi_Livehandler_Model_Ordergrid
  • Eabi_Livehandler_Model_System_Config_Backend_Button
  • Eabi_Postoffice_Adminhtml_PostofficeController
  • Eabi_Postoffice_Block_Adminhtml_Config_Form_Field_License
  • Eabi_Postoffice_Block_Adminhtml_Config_Form_Field_Remove
  • Eabi_Postoffice_Block_Config_Rebuildbutton
  • Eabi_Postoffice_Helper_Countrycode
  • Eabi_Postoffice_Helper_Data
  • Eabi_Postoffice_IndexController
  • Eabi_Postoffice_Model_Carrier_Abstract
  • Eabi_Postoffice_Model_Carrier_Result
  • Eabi_Postoffice_Model_Carriermodule
  • Eabi_Postoffice_Model_Mysql4_Carriermodule
  • Eabi_Postoffice_Model_Mysql4_Carriermodule_Collection
  • Eabi_Postoffice_Model_Mysql4_Office
  • Eabi_Postoffice_Model_Mysql4_Office_Collection
  • Eabi_Postoffice_Model_Observer
  • Eabi_Postoffice_Model_Office
  • Eabi_Postoffice_Model_Orderview
  • Eabi_Postoffice_Model_Source_Sendevent
  • Eabi_Postoffice_Model_Updater
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /*
  4:   
  5:  *
  6:  * NOTICE OF LICENSE
  7:  *
  8:  * This source file is subject to the Open Software License (OSL 3.0)
  9:  * or OpenGPL v3 license (GNU Public License V3.0)
 10:  * that is bundled with this package in the file LICENSE.txt.
 11:  * It is also available through the world-wide-web at this URL:
 12:  * http://opensource.org/licenses/osl-3.0.php
 13:  * or
 14:  * http://www.gnu.org/licenses/gpl-3.0.txt
 15:  * If you did not receive a copy of the license and are unable to
 16:  * obtain it through the world-wide-web, please send an email
 17:  * to info@e-abi.ee so we can send you a copy immediately.
 18:  *
 19:  * DISCLAIMER
 20:  *
 21:  * Do not edit or add to this file if you wish to upgrade this module to newer
 22:  * versions in the future.
 23:  *
 24:  * @category   Eabi
 25:  * @package    Eabi_Dpd
 26:  * @copyright  Copyright (c) 2014 Aktsiamaailm LLC (http://en.e-abi.ee/)
 27:  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 28:  * @license    http://www.gnu.org/licenses/gpl-3.0.txt  GNU Public License V3.0
 29:  * @author     Matis Halmann
 30:  * 
 31: 
 32:  */
 33: 
 34: /**
 35:  * <p>Holds all Mage::dispatchEvent() actions</p>
 36:  *
 37:  * @author Matis
 38:  */
 39: class Eabi_DpdEE_Model_Observer {
 40:     
 41:     
 42:     /**
 43:      * <p>Adds tracking numbers to orders created with DPD right after shipment is first time saved</p>
 44:      * <p>If parcel data is not sent to server, then tracking numbers will not be created, even if data is sent to server after creation of shipment</p>
 45:      * @param Varien_Event_Observer $observer
 46:      */
 47:     public function addTrackingToShipment($observer) {
 48:         /* @var $shipment Mage_Sales_Model_Order_Shipment */
 49:         $shipment = $observer->getEvent()->getShipment();
 50:         if ($shipment
 51:                 && $this->_getDpdHelper()->isShippingMethodApplicable($shipment->getOrder())) {
 52:             //add the tracks here.....
 53:             $dataSavedToOrder = $this->_getOfficeHelper()->getDataFromOrder($shipment->getOrder(), Eabi_DpdEE_Model_Post::ORDER_COMMENT_START_PREFIX);
 54:             if (isset($dataSavedToOrder['Parcel_numbers'])) {
 55:                 $this->_addTracksToShipment($shipment, $dataSavedToOrder['Parcel_numbers']);
 56:             }
 57:             
 58:         }
 59:     }
 60: 
 61:     
 62:     /**
 63:      * <p>Adds tracking numbers to shipment, when it is known that we are dealing with DPD order</p>
 64:      * <p>If tracks with same carrier code as order shipping method carrier code have already been added, then this function does nothing</p>
 65:      * @param Mage_Sales_Model_Order_Shipment $shipment shipment, to add the tracking numbers for
 66:      * @param array $trackingNumbers array of DPD tracking numbers
 67:      */
 68:     protected function _addTracksToShipment(Mage_Sales_Model_Order_Shipment $shipment, array $trackingNumbers) {
 69:         /* @var $shippingMethodInstance Eabi_Postoffice_Model_Carrier_Abstract */
 70:         $shippingMethodInstance = $this->_getOfficeHelper()->getShippingMethodInstance($shipment->getOrder()->getIncrementId());
 71:         $trackExists = false;
 72:         if ($shippingMethodInstance) {
 73:             $oldTracks = $shipment->getAllTracks();
 74:             foreach ($oldTracks as $oldTrack) {
 75:                 if ($oldTrack->getCarrierCode() == $shippingMethodInstance->getCarrierCode()) {
 76:                     $trackExists = true;
 77:                 }
 78:             }
 79:             if (!$trackExists) {
 80:                 foreach ($trackingNumbers as $trackingNumber) {
 81:                     $track = $this->_getTrackingModel()
 82:                             ->setNumber($trackingNumber)
 83:                             ->setCarrierCode($shippingMethodInstance->getCarrierCode())
 84:                             ->setTitle($shippingMethodInstance->getConfigData('title'))
 85:                             ->setShipment($shipment);
 86:                     $track->save();
 87:                 }
 88:             }
 89:         }
 90:     }
 91:     
 92:     
 93:     
 94:     /**
 95:      * <p>Applies payment method fee under adminhtml at order create</p>
 96:      * @param Varien_Event_Observer $observer
 97:      */
 98:     public function applyPaymentMethodFee($observer) {
 99:         /* @var $orderCreateModel Mage_Adminhtml_Model_Sales_Order_Create */
100:         $orderCreateModel = $observer->getEvent()->getOrderCreateModel();
101: 
102:         if ($orderCreateModel->getQuote()->getPayment()->getMethod() == Eabi_DpdEE_Model_Config::PAYMENT_METHOD_COD) {
103:             $orderCreateModel->getShippingAddress()->setCollectShippingRates(true);
104:         }
105:     }
106:     
107: 
108:     /**
109:      * 
110:      * @return Mage_Sales_Model_Order_Shipment_Track
111:      */
112:     protected function _getTrackingModel() {
113:         return Mage::getModel('sales/order_shipment_track');
114:     }
115:     
116:     
117:     /**
118:      * 
119:      * @return Eabi_DpdEE_Helper_Data
120:      */
121:     protected function _getDpdHelper() {
122:         return Mage::helper('eabi_dpdee');
123:     }
124:     
125:     /**
126:      * 
127:      * @return Eabi_Postoffice_Helper_Data
128:      */
129:     protected function _getOfficeHelper() {
130:         return Mage::helper('eabi_postoffice');
131:     }
132:     
133:     
134:     
135: }
136: 
DPD Eesti - Pakivedu.ee Shipping module for Magento API documentation generated by ApiGen 2.8.0