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>Represents DPD courier shipping method.</p>
 36:  * <p>Extra order data is stored under specialized order comment</p>
 37:  * <p>Can perform following business actions:</p>
 38:  * <ul>
 39:      <li>Calculate shipping price based on country and weight</li>
 40:      <li>Send information about shipment data to DPD server.</li>
 41:      <li>Display tracking link to user when tracking code is added to the shipment.</li>
 42:      <li>Call courier to pick up the shipment that was ordered using this carrier.</li>
 43:      <li>Print out packing slip PDF from Order view.</li>
 44:  </ul>
 45:  *
 46:  * @author Matis
 47:  */
 48: class Eabi_DpdEE_Model_Flat extends Eabi_DpdEE_Model_Post {
 49:     protected $_code = Eabi_DpdEE_Model_Config::SHIPPING_METHOD_CODE_FLAT;
 50:     protected $_parent_code = Eabi_DpdEE_Model_Config::SHIPPING_METHOD_CODE_PARCEL_TERMINAL;
 51:     
 52:     
 53:     /**
 54:      * <p>If disable shipping by product comment is allowed and product's short description in shopping cart contains html comment &lt;!-- no dpd_ee_module --&gt; then it returns false.</p>
 55:      * @param Mage_Shipping_Model_Rate_Request $request
 56:      * @return boolean true if this method is available.
 57:      * @see Eabi_Postoffice_Model_Carrier_Abstract::_isAvailable()
 58:      */
 59:     protected function _isAvailable(Mage_Shipping_Model_Rate_Request $request) {
 60:         $productItem = true;
 61:         if ($this->getConfigData('checkitems') == 1) {
 62:             $productItem = true;
 63:             if ($request->getAllItems()) {
 64:                 foreach ($request->getAllItems() as $item) {
 65:                     $custom = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
 66:                     $desc = $custom->getShortDescription();
 67:                     if (stristr($desc, '<!-- no dpd_ee_module -->')) {
 68:                         $productItem = false;
 69:                         break;
 70:                     }
 71:                     if (stristr($desc, '<!-- no dpd_ee_courier -->')) {
 72:                         $productItem = false;
 73:                         break;
 74:                     }
 75:                 }
 76:             }
 77:         }
 78:         if (!$productItem) {
 79:             return false;
 80:         }
 81:         return true;
 82:     }
 83:     
 84:     
 85:     /**
 86:      * Automatic data sending is defined in Parcel terminal module configuration
 87:      * @return bool
 88:      */
 89:     public function isAutoSendAvailable() {
 90:         return (bool)$this->_getDpdHelper()->getApi($this->getStore(), $this->_parent_code)->getConfigData('senddata_enable');
 91:     }
 92:     
 93:     
 94:     /**
 95:      * <p>Sends parcel data to DPD server for specified order</p>
 96:      * @param Mage_Sales_Model_Order $order
 97:      * @param type $selectedOfficeId not applicable.
 98:      * @return array comma separated parcel numbers in array key of 'barcode'
 99:      */
100:     public function autoSendData(Mage_Sales_Model_Order $order, $selectedOfficeId) {
101:         $shippingAddress = $order->getShippingAddress();
102:         $requestData = array(
103:             'Sh_name' => $shippingAddress->getName(),
104:             'Sh_company' => $shippingAddress->getCompany(),
105:             'Sh_street' => $shippingAddress->getStreetFull(),
106:             'Sh_postal' => $shippingAddress->getPostcode(),
107:             'Sh_country' => strtolower($shippingAddress->getCountryId()),
108:             'Sh_city' => $shippingAddress->getCity(),
109:             'Sh_contact' => $shippingAddress->getName(),
110:             'Sh_phone' => $shippingAddress->getTelephone(),
111:             'Po_remark' => $this->_getRemark($order),
112:             'Sh_remark' => '',
113:             'Sh_pudo' => 'false',
114:             'Sh_parcel_qty' => $this->_getNumberOfPackagesForOrder($order),
115:             'Sh_cust_reference' => $order->getIncrementId(),
116:         );
117:         if ($shippingAddress->getRegion()) {
118:             $requestData['Sh_city'] = $shippingAddress->getCity() . ', ' . $shippingAddress->getRegion();
119:         }
120:         //add cash on delivery
121:         if ($order->getTotalDue() > 0) {
122:             $requestData['Sh_cod_amount'] = number_format(round($order->getTotalDue(), 2), 2, '.', '');
123:             $requestData['Sh_cod_currency'] = $order->getCurrency();
124:         }
125:         
126:         
127:         $requestResult = $this->_getDpdHelper()->getApi($this->getStore(), $this->_parent_code)
128:                 ->autoSendData($requestData);
129:         
130:         $this->_setDataToOrder($order, $requestResult);
131:         
132:         //on failure return false
133:         //is success
134:         return array('barcode' => '##'.  implode(',', $requestResult['Parcel_numbers']).'##');
135:     }
136:     
137:         
138:     
139:     /**
140:      * <p>This carrier has no parcel terminal selection feature, so one entry must still be added with shipping method title defined for this carrier.</p>
141:      * @return array single office element
142:      */
143:     public function getOfficeList() {
144:         //we have only one item to insert here
145:         $result = array();
146:         $result[] = array(
147:             'place_id' => 1,
148:             'name' => $this->getConfigData('title'),
149:             'city' => '',
150:             'county' => '',
151:             'description' => '',
152:             'country' => '',
153:             'zip' => '',
154:             'group_sort' => 0,
155:         );
156:         return $result;
157:     }
158:     
159:     /**
160:      * <p>Returns carrier title specified for this shipping method.</p>
161:      * @param Eabi_Postoffice_Model_Office $office
162:      * @return string
163:      * @see Eabi_Postoffice_Model_Carrier_Abstract::getTerminalTitle()
164:      */
165:     public function getTerminalTitle(Eabi_Postoffice_Model_Office $office) {
166:         return htmlspecialchars($this->getConfigData('title'));
167:     }
168:     
169:     
170:     /**
171:      * <p>Returns carrier title specified for this shipping method.</p>
172:      * @param Eabi_Postoffice_Model_Office $office
173:      * @return string
174:      * @see Eabi_Postoffice_Model_Carrier_Abstract::getAdminTerminalTitle()
175:      */
176:     public function getAdminTerminalTitle(Eabi_Postoffice_Model_Office $office) {
177:         return htmlspecialchars($this->getConfigData('title'));
178:     }
179:     
180:     /**
181:      * <p>Indicates if specified order has been picked up by courier.</p>
182:      * <p>Should return the following</p>
183:      * <ul>
184:          <li><b>true</b> - If the order has been picked up by courier</li>
185:          <li><b>false</b> - If the order has not been picked up by courier</li>
186:          <li><b>null</b> - If courier pickup is not applicable to specified order</li>
187:      </ul>
188:      * @param Mage_Sales_Model_Order $order
189:      * @return null|bool
190:      */
191:     public function isPickedUpByCourier(Mage_Sales_Model_Order $order) {
192:         $api = $this->_getDpdHelper()->getApi($this->getStore()->getId(), $this->_parent_code);
193:         if (!$api->getConfigData('courier_enable')) {
194:             return null;
195:         }
196:         $orderData = $this->getDataFromOrder($order);
197:         if (isset($orderData['courier_call_id']) && $orderData['courier_call_id']) {
198:             return true;
199:         }
200:         return false;
201:     }
202:     
203:     /**
204:      * <p>Nullifies address id from query, because in every country there needs to be available 'parcel-terminal'</p>
205:      * @param int $groupId
206:      * @param int $addressId
207:      * @return array
208:      * @see Eabi_Postoffice_Model_Carrier_Abstract::getTerminals()
209:      */
210:     public function getTerminals($groupId = null, $addressId = null) {
211:         //fetching entry needs to be independendent of country
212:         return parent::getTerminals($groupId, null);
213:     }
214:     
215: 
216:     /**
217:      * <p>Nullifies address id from query, because in every country there needs to be available 'parcel-terminal'</p>
218:      * @param int $addressId
219:      * @return array
220:      * @see Eabi_Postoffice_Model_Carrier_Abstract::getGroups()
221:      */
222:     public function getGroups($addressId = null) {
223:         return parent::getGroups(null);
224:         
225:     }
226:     
227:     
228: 
229:     /**
230:      * Gets the config data from this instance and if not existent, then tries to fetch it from parent instance.
231:      * 
232:      * @param string $field
233:      * @return mixed
234:      */
235:     public function getConfigData($field) {
236:         if (empty($this->_code)) {
237:             return false;
238:         }
239:         $path = 'carriers/'.$this->_code.'/'.$field;
240:         $value = $this->_getConfigDataOverride($field, $this->_code);
241: //        $value = Mage::getStoreConfig($path, $this->getStore());
242:         if ($value === false || $value === null) {
243:             $path = 'carriers/'.$this->_parent_code.'/'.$field;
244:             return $this->_getConfigDataOverride($field, $this->_parent_code);
245: //            return Mage::getStoreConfig($path, $this->getStore());
246:         } else {
247:             return $value;
248:         }
249:     }
250:     
251:     
252:     
253: 
254: }
255: 
DPD Eesti - Pakivedu.ee Shipping module for Magento API documentation generated by ApiGen 2.8.0