ParcelPro_Carrier - Version 1.0.1

Version Notes

Version 1.0.1
Actually use default location for ShipFrom
Some error logging added

Version 1.0.0
New release.

Download this release

Release Info

Developer Parcel Pro, Inc. Joey Chan, Project Lead Jasper Lynn, Project Manager
Extension ParcelPro_Carrier
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/community/ParcelPro/Carrier/Block/Adminhtml/Button/Refresh/Cms.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ParcelPro_Carrier_Block_Adminhtml_Button_Refresh_Cms extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /**
6
+ * Import static blocks
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ * @return String
10
+ */
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
12
+ {
13
+ $elementOriginalData = $element->getOriginalData();
14
+ if (isset($elementOriginalData['process']))
15
+ {
16
+ $name = $elementOriginalData['process'];
17
+ }
18
+ else
19
+ {
20
+ return '<div>Action was not specified</div>';
21
+ }
22
+
23
+ $buttonSuffix = '';
24
+ if (isset($elementOriginalData['label']))
25
+ $buttonSuffix = ' ' . $elementOriginalData['label'];
26
+
27
+ $url = $this->getUrl('parcelpro_carrier/adminhtml_refresh/' . $name);
28
+
29
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')
30
+ ->setType('button')
31
+ ->setClass('import-cms')
32
+ ->setLabel('Refresh' . $buttonSuffix)
33
+ ->setOnClick("setLocation('$url')")
34
+ ->toHtml();
35
+
36
+ return $html;
37
+ }
38
+ }
app/code/community/ParcelPro/Carrier/Helper/Parcelpro.php ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Usa data helper
29
+ *
30
+ * @author Magento Core Team <core@magentocommerce.com>
31
+ */
32
+ class ParcelPro_Carrier_Helper_Parcelpro extends Mage_Core_Helper_Abstract
33
+ {
34
+ private $_base_url;
35
+ private $_version;
36
+ private $_auth_path;
37
+ private $_location_path;
38
+ private $_addressbook_path;
39
+
40
+ private $_single_quote_path;
41
+ private $_shipment_path;
42
+ private $_highvalue_path;
43
+ private $_estimator_path;
44
+ private $_carrierservices_path;
45
+ private $_packagetypes_path;
46
+ private $_zipcodevalidator_path;
47
+ private $_addressvalidator_path;
48
+
49
+ private $_sessionId = null;
50
+
51
+ protected $_code = 'parcelpro_carrier';
52
+
53
+ public function __construct()
54
+ {
55
+ $this->_base_url = 'https://apibeta.parcelpro.com/';
56
+
57
+ if(Mage::getStoreConfig('carriers/parcelpro/sandbox_mode') == 1){
58
+ $this->_base_url = 'https://apibeta.parcelpro.com/';
59
+ }else{
60
+ $this->_base_url = 'https://api.parcelpro.com/';
61
+ }
62
+
63
+ $this->_version = 'v1.1/';
64
+ //$this->_version = 'v1/';
65
+ $this->_auth_path = 'auth';
66
+ $this->_location_path = 'location';
67
+ $this->_addressbook_path = 'addressbook';
68
+ $this->_quote_path = 'quote';
69
+ $this->_shipment_path = 'shipment';
70
+ $this->_highvalue_path = 'highvalue';
71
+ $this->_estimator_path = 'estimator';
72
+ $this->_carrierservices_path = 'carrierservices';
73
+ $this->_packagetypes_path = 'packagetypes';
74
+ $this->_zipcodevalidator_path = 'zipcodevalidator';
75
+ $this->_addressvalidator_path = 'addressvalidator';
76
+
77
+ }
78
+ public function updateSpecialServices(){
79
+ $this->_deleteConfig('special_services');
80
+ $model = Mage::getModel('carrier/config');
81
+ $upsSpecialServices = array(
82
+ 'NO_SIGNATURE_REQUIRED' => Mage::helper('usa')->__('Not Required'),
83
+ 'DIRECT' => Mage::helper('usa')->__('Direct Signature'),
84
+ 'saturday_pickup' => Mage::helper('usa')->__('Saturday pickup'),
85
+ 'saturday_delivery' => Mage::helper('usa')->__('Saturday delivery'),
86
+ 'thermal_label' => Mage::helper('usa')->__('Thermal label'),
87
+ );
88
+ foreach ($upsSpecialServices as $key => $val){
89
+ $model->setCarrier('UPS')
90
+ ->setConfigType('special_services')
91
+ ->setConfigKey($key)
92
+ ->setConfigValue($val)
93
+ ->setApplyTo('UPS')
94
+ ->save();
95
+ $model->unsetData();
96
+ }
97
+ $fedexSpecialServices = array(
98
+ 'NO_SIGNATURE_REQUIRED' => Mage::helper('usa')->__('Not Required'),
99
+ 'ADULT' => Mage::helper('usa')->__('Adult Signature'),
100
+ 'DIRECT' => Mage::helper('usa')->__('Direct Signature'),
101
+ 'saturday_pickup' => Mage::helper('usa')->__('Saturday pickup'),
102
+ 'saturday_delivery' => Mage::helper('usa')->__('Saturday delivery'),
103
+ 'thermal_label' => Mage::helper('usa')->__('Thermal label'),
104
+
105
+ );
106
+ foreach ($fedexSpecialServices as $key => $val){
107
+ $model->setCarrier('FEDEX')
108
+ ->setConfigType('special_services')
109
+ ->setConfigKey($key)
110
+ ->setConfigValue($val)
111
+ ->setApplyTo('FEDEX')
112
+ ->save();
113
+ $model->unsetData();
114
+ }
115
+ }
116
+
117
+ public function updatePackageTypes(){
118
+ $model = Mage::getModel('carrier/config');
119
+ $collection = $model->getCollection()
120
+ ->addFieldToFilter('config_type',array('eq'=>'carrier'));
121
+ foreach($collection as $row){
122
+ $this->_deleteConfig('packaging', $row->getConfigValue());
123
+ $carrierServices = $model->getCollection()
124
+ ->addFieldToFilter('config_type',array('eq'=>'method'))->addFieldToFilter('carrier',array('eq'=>$row->getConfigValue()));
125
+ foreach ($carrierServices as $carrierService){
126
+ $queryString = 'carrierservicecode='.$carrierService->getConfigKey().'&carriercode='.$row->getConfigValue();
127
+ $packageTypes = $this->_sendRequest($this->_packagetypes_path, $queryString, array());
128
+ if($packageTypes){
129
+ foreach ($packageTypes as $packageType){
130
+ $model->setCarrier($row->getConfigValue())
131
+ ->setConfigType('packaging')
132
+ ->setConfigKey($packageType->PackageTypeCode)
133
+ ->setConfigValue($packageType->PackageTypeDesc)
134
+ ->setApplyTo($carrierService->getConfigKey())
135
+ ->save();
136
+ $model->unsetData();
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+
143
+ public function updateCarrierServices(){
144
+ $model = Mage::getModel('carrier/config');
145
+ $collection = $model->getCollection()
146
+ ->addFieldToFilter('config_type',array('eq'=>'carrier'));
147
+ foreach($collection as $row){
148
+ $this->_deleteConfig('method', $row->getConfigValue());
149
+ $queryString = 'carriercode='.$row->getConfigValue().'&domesticonly=False';
150
+ $carrierServices = $this->_sendRequest($this->_carrierservices_path, $queryString, array());
151
+ if($carrierServices){
152
+ foreach ($carrierServices as $service){
153
+ $model->setCarrier($row->getConfigValue())
154
+ ->setConfigType('method')
155
+ ->setConfigKey($service->ServiceCode)
156
+ ->setConfigValue($service->ServiceCodeDesc)
157
+ ->save();
158
+ $model->unsetData();
159
+ }
160
+ }
161
+
162
+ $queryString = 'carriercode='.$row->getConfigValue().'&domesticonly=True';
163
+ $carrierServices = $this->_sendRequest($this->_carrierservices_path, $queryString, array());
164
+ if($carrierServices){
165
+ foreach ($carrierServices as $service){
166
+ $model->setCarrier($row->getConfigValue())
167
+ ->setConfigType('method')
168
+ ->setConfigKey($service->ServiceCode)
169
+ ->setConfigValue($service->ServiceCodeDesc)
170
+ ->save();
171
+ $model->unsetData();
172
+ }
173
+ }
174
+ }
175
+ }
176
+
177
+ public function updateCarriers(){
178
+ $model = Mage::getModel('carrier/config');
179
+ $this->_deleteConfig('carrier');
180
+ $model->setCarrier('')
181
+ ->setConfigType('carrier')
182
+ ->setConfigKey('UPS')
183
+ ->setConfigValue('UPS')
184
+ ->setApplyTo('1')
185
+ ->save();
186
+ $model->unsetData();
187
+ $model->setCarrier('')
188
+ ->setConfigType('carrier')
189
+ ->setConfigKey('FEDEX')
190
+ ->setConfigValue('FEDEX')
191
+ ->setApplyTo('2')
192
+ ->save();
193
+ return true;
194
+ }
195
+
196
+ private function _deleteConfig($type, $carrier = null){
197
+ $model = Mage::getModel('carrier/config');
198
+ if($carrier){
199
+ $collection = $model->getCollection()
200
+ ->addFieldToFilter('config_type',array('eq'=>$type))->addFieldToFilter('carrier',array('eq'=>$carrier));
201
+ }else{
202
+ $collection = $model->getCollection()
203
+ ->addFieldToFilter('config_type',array('eq'=>$type));
204
+ }
205
+ foreach($collection as $row){
206
+ $row->delete();
207
+ }
208
+ }
209
+ private function _sendRequest($requestPath, $queryString, $parrams, $isPost = false){
210
+ if(!$this->_sessionId){
211
+ $this->_getSessionId();
212
+ }
213
+
214
+ if($this->_sessionId){
215
+ $url = $this->_base_url . $this->_version . $requestPath . '?' . $queryString .'&sessionID=' . $this->_sessionId;
216
+ $ch = curl_init();
217
+ curl_setopt($ch, CURLOPT_URL, $url);
218
+ if($isPost){
219
+ curl_setopt($ch, CURLOPT_POST, 1);
220
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($parrams));
221
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
222
+ 'Content-Type: application/json',
223
+ 'Content-Length: ' . strlen(json_encode($parrams)))
224
+ );
225
+ }else{
226
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
227
+ 'Content-Type: application/json',
228
+ )
229
+ );
230
+ }
231
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
232
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
233
+
234
+ $data = curl_exec ($ch);
235
+ curl_close ($ch);
236
+ if($data){
237
+ if($isPost){
238
+ $result = json_decode($data);
239
+ }else{
240
+ $result = json_decode($data);
241
+ }
242
+ return $result;
243
+ }else{
244
+ return null;
245
+ }
246
+ }else{
247
+ return null;
248
+ }
249
+ }
250
+
251
+ private function _getSessionId(){
252
+ $model = Mage::getModel('carrier/config');
253
+ $collection = $model->getCollection()
254
+ ->addFieldToFilter('config_type',array('eq'=>'session_id'));
255
+ if($collection->count()){
256
+ $item = $collection->getFirstItem();
257
+ if($this->_checkInvalideSession($item->getConfigValue())){
258
+ $this->_sessionId = $item->getConfigValue();
259
+ return $item->getConfigValue();
260
+ }else{
261
+ $item->delete();
262
+ }
263
+ }
264
+
265
+ $username = Mage::helper('core')->decrypt(Mage::getStoreConfig('carriers/parcelpro/account'));
266
+ $password = Mage::helper('core')->decrypt(Mage::getStoreConfig('carriers/parcelpro/password'));
267
+ $apikey = Mage::helper('core')->decrypt(Mage::getStoreConfig('carriers/parcelpro/key'));
268
+
269
+ $ch = curl_init();
270
+ $auth_url = $this->_base_url . $this->_version . $this->_auth_path;
271
+ $auth_url .= '?username='.$username.'&password='.$password.'&apikey='.$apikey;
272
+
273
+ curl_setopt($ch, CURLOPT_URL, $auth_url);
274
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
275
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
276
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
277
+ 'Content-Type: application/json',
278
+ )
279
+ );
280
+
281
+ $authData = curl_exec ($ch);
282
+ curl_close ($ch);
283
+ if($authData){
284
+ $result = json_decode($authData);
285
+ $this->_sessionId = $result->SessionID;
286
+ $this->_checkInvalideSession($result->SessionID);
287
+ if($result->Message)
288
+ Mage::log('getSessionId:'.$result->Message,null,'ppimagento.log');
289
+
290
+ $model->setCarrier("")
291
+ ->setConfigType('session_id')
292
+ ->setConfigKey('session_id')
293
+ ->setConfigValue($result->SessionID)
294
+ ->save();
295
+ $model->unsetData();
296
+
297
+ return $result->SessionID;
298
+ }else{
299
+ return false;
300
+ }
301
+ }
302
+
303
+ private function _checkInvalideSession($sessionId){
304
+ if($sessionId == null || $sessionId == ""){
305
+ return false;
306
+ }
307
+ $ch = curl_init();
308
+ $location_url = $this->_base_url . $this->_version . $this->_location_path;
309
+ $location_url .= '?sessionID=' . $sessionId;
310
+
311
+ curl_setopt($ch, CURLOPT_URL, $location_url);
312
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
313
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
314
+ $locationData = curl_exec ($ch);
315
+ $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
316
+ curl_close ($ch);
317
+ if($http_status == '401'){
318
+ return false;
319
+ }else{
320
+ return true;
321
+ }
322
+ }
323
+ }
app/code/community/ParcelPro/Carrier/Model/Carrier.php ADDED
@@ -0,0 +1,1317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ParcelPro_Carrier_Model_Carrier extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
3
+
4
+ private $_base_url;
5
+ private $_version;
6
+ private $_auth_path;
7
+ private $_location_path;
8
+ private $_addressbook_path;
9
+
10
+ private $_single_quote_path;
11
+ private $_quote_path;
12
+ private $_shipment_path;
13
+ private $_highvalue_path;
14
+ private $_estimator_path;
15
+ private $_carrierservices_path;
16
+ private $_packagetypes_path;
17
+ private $_zipcodevalidator_path;
18
+ private $_addressvalidator_path;
19
+
20
+ private $_sessionId = null;
21
+
22
+ protected $_code = 'parcelpro';
23
+
24
+ /**
25
+ * Rate result data
26
+ *
27
+ * @var Mage_Shipping_Model_Rate_Result|null
28
+ */
29
+ protected $_result = null;
30
+
31
+ public function __construct()
32
+ {
33
+ if($this->getConfigData('sandbox_mode') == 1){
34
+ $this->_base_url = 'https://apibeta.parcelpro.com/';
35
+ }else{
36
+ $this->_base_url = 'https://api.parcelpro.com/';
37
+ }
38
+ $this->_version = 'v1.1/';
39
+ //$this->_version = 'v1/';
40
+ $this->_auth_path = 'auth';
41
+ $this->_location_path = 'location';
42
+ $this->_addressbook_path = 'addressbook';
43
+ $this->_quote_path = 'quote';
44
+ $this->_shipment_path = 'shipment';
45
+ $this->_highvalue_path = 'highvalue';
46
+ $this->_estimator_path = 'estimator';
47
+ $this->_carrierservices_path = 'carrierservices';
48
+ $this->_packagetypes_path = 'packagetypes';
49
+ $this->_zipcodevalidator_path = 'zipcodevalidator';
50
+ $this->_addressvalidator_path = 'addressvalidator';
51
+ $this->_user_path = 'user';
52
+
53
+ }
54
+
55
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
56
+ $result = Mage::getModel('shipping/rate_result');
57
+ if($this->getConfigData('allowed_carriers')){
58
+ $_rawRequest = $this->_collectRequestData($request);
59
+ //Mage::log(json_encode($_rawRequest));
60
+ $estimatorData = $this->_sendRequest($this->_estimator_path, $_rawRequest, true);
61
+
62
+ $rateList = $this->_parseShippingRates($estimatorData);
63
+
64
+ if($rateList){
65
+ foreach ($rateList as $rate){
66
+ $result->append($rate);
67
+ }
68
+ }
69
+ $this->_result = $result;
70
+ }
71
+ return $result;
72
+
73
+ }
74
+ public function getAllowedMethods() {
75
+ $arr = array();
76
+ $allMethods = $this->getCode('method');
77
+
78
+ $allMethodOptions = array();
79
+ if($allMethods){
80
+ foreach ($allMethods as $key =>$val){
81
+ $allMethodOptions[$key] = $val;
82
+ }
83
+ }
84
+ $upsAllowed = explode(',', $this->getConfigData('allowed_ups_methods'));
85
+ foreach ($upsAllowed as $k) {
86
+ if(isset($allMethodOptions[$k])){
87
+ $arr[$k] = $allMethodOptions[$k];
88
+ }
89
+ }
90
+
91
+ $fedexAllowed = explode(',', $this->getConfigData('allowed_fedex_methods'));
92
+ foreach ($fedexAllowed as $k) {
93
+ if(isset($allMethodOptions[$k])){
94
+ $arr[$k] = $allMethodOptions[$k];
95
+ }
96
+ }
97
+ return $arr;
98
+ }
99
+
100
+ /**
101
+ * Check if carrier has shipping tracking option available
102
+ * All Mage_Usa carriers have shipping tracking option available
103
+ *
104
+ * @return boolean
105
+ */
106
+ public function isTrackingAvailable()
107
+ {
108
+ return true;
109
+ }
110
+
111
+ public function isShippingLabelsAvailable()
112
+ {
113
+ return true;
114
+ }
115
+
116
+ /**
117
+ * Return items for further shipment rate evaluation. We need to pass children of a bundle instead passing the
118
+ * bundle itself, otherwise we may not get a rate at all (e.g. when total weight of a bundle exceeds max weight
119
+ * despite each item by itself is not)
120
+ *
121
+ * @param Mage_Shipping_Model_Rate_Request $request
122
+ * @return array
123
+ */
124
+ public function getAllItems(Mage_Shipping_Model_Rate_Request $request)
125
+ {
126
+ $items = array();
127
+ if ($request->getAllItems()) {
128
+ foreach ($request->getAllItems() as $item) {
129
+ /* @var $item Mage_Sales_Model_Quote_Item */
130
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
131
+ // Don't process children here - we will process (or already have processed) them below
132
+ continue;
133
+ }
134
+
135
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
136
+ foreach ($item->getChildren() as $child) {
137
+ if (!$child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
138
+ $items[] = $child;
139
+ }
140
+ }
141
+ } else {
142
+ // Ship together - count compound item as one solid
143
+ $items[] = $item;
144
+ }
145
+ }
146
+ }
147
+ return $items;
148
+ }
149
+
150
+ /**
151
+ * Processing additional validation to check if carrier applicable.
152
+ *
153
+ * @param Mage_Shipping_Model_Rate_Request $request
154
+ * @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean
155
+ */
156
+ /*
157
+ public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request)
158
+ {
159
+ //Skip by item validation if there is no items in request
160
+ if(!count($this->getAllItems($request))) {
161
+ return $this;
162
+ }
163
+
164
+ $maxAllowedWeight = (float) $this->getConfigData('max_package_weight');
165
+ $errorMsg = '';
166
+ $configErrorMsg = $this->getConfigData('specificerrmsg');
167
+ $defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.');
168
+ $showMethod = $this->getConfigData('showmethod');
169
+
170
+ foreach ($this->getAllItems($request) as $item) {
171
+ if ($item->getProduct() && $item->getProduct()->getId()) {
172
+ $weight = $item->getProduct()->getWeight();
173
+ $stockItem = $item->getProduct()->getStockItem();
174
+ $doValidation = true;
175
+
176
+ if ($stockItem->getIsQtyDecimal() && $stockItem->getIsDecimalDivided()) {
177
+ if ($stockItem->getEnableQtyIncrements() && $stockItem->getQtyIncrements()) {
178
+ $weight = $weight * $stockItem->getQtyIncrements();
179
+ } else {
180
+ $doValidation = false;
181
+ }
182
+ } elseif ($stockItem->getIsQtyDecimal() && !$stockItem->getIsDecimalDivided()) {
183
+ $weight = $weight * $item->getQty();
184
+ }
185
+
186
+ if ($doValidation && $weight > $maxAllowedWeight) {
187
+ $errorMsg = ($configErrorMsg) ? $configErrorMsg : $defaultErrorMsg;
188
+ break;
189
+ }
190
+ }
191
+ }
192
+
193
+ if (!$errorMsg && !$request->getDestPostcode() && $this->isZipCodeRequired($request->getDestCountryId())) {
194
+ $errorMsg = Mage::helper('shipping')->__('This shipping method is not available, please specify ZIP-code');
195
+ }
196
+
197
+ if ($errorMsg && $showMethod) {
198
+ $error = Mage::getModel('shipping/rate_result_error');
199
+ $error->setCarrier($this->_code);
200
+ $error->setCarrierTitle($this->getConfigData('title'));
201
+ $error->setErrorMessage($errorMsg);
202
+ return $error;
203
+ } elseif ($errorMsg) {
204
+ return false;
205
+ }
206
+ return $this;
207
+ }
208
+ */
209
+ /**
210
+ * Returns cache key for some request to carrier quotes service
211
+ *
212
+ * @param string|array $requestParams
213
+ * @return string
214
+ */
215
+ protected function _getQuotesCacheKey($requestParams)
216
+ {
217
+ if (is_array($requestParams)) {
218
+ $requestParams = implode(',', array_merge(
219
+ array($this->getCarrierCode()),
220
+ array_keys($requestParams),
221
+ $requestParams)
222
+ );
223
+ }
224
+ return crc32($requestParams);
225
+ }
226
+
227
+ /**
228
+ * Checks whether some request to rates have already been done, so we have cache for it
229
+ * Used to reduce number of same requests done to carrier service during one session
230
+ *
231
+ * Returns cached response or null
232
+ *
233
+ * @param string|array $requestParams
234
+ * @return null|string
235
+ */
236
+ protected function _getCachedQuotes($requestParams)
237
+ {
238
+ $key = $this->_getQuotesCacheKey($requestParams);
239
+ return isset(self::$_quotesCache[$key]) ? self::$_quotesCache[$key] : null;
240
+ }
241
+
242
+ /**
243
+ * Sets received carrier quotes to cache
244
+ *
245
+ * @param string|array $requestParams
246
+ * @param string $response
247
+ * @return Mage_Usa_Model_Shipping_Carrier_Abstract
248
+ */
249
+ protected function _setCachedQuotes($requestParams, $response)
250
+ {
251
+ $key = $this->_getQuotesCacheKey($requestParams);
252
+ self::$_quotesCache[$key] = $response;
253
+ return $this;
254
+ }
255
+
256
+ /**
257
+ * Prepare service name. Strip tags and entities from name
258
+ *
259
+ * @param string|object $name service name or object with implemented __toString() method
260
+ * @return string prepared service name
261
+ */
262
+ protected function _prepareServiceName($name)
263
+ {
264
+ $name = html_entity_decode((string)$name);
265
+ $name = strip_tags(preg_replace('#&\w+;#', '', $name));
266
+ return trim($name);
267
+ }
268
+
269
+
270
+ public function getTrackingInfo($tracking)
271
+ {
272
+ $info = array();
273
+
274
+ $result = $this->getTracking($tracking);
275
+
276
+ if($result instanceof Mage_Shipping_Model_Tracking_Result){
277
+ if ($trackings = $result->getAllTrackings()) {
278
+ return $trackings[0];
279
+ }
280
+ }
281
+ elseif (is_string($result) && !empty($result)) {
282
+ return $result;
283
+ }
284
+
285
+ return false;
286
+ }
287
+
288
+ /**
289
+ * Get tracking
290
+ *
291
+ * @param mixed $trackings
292
+ * @return mixed
293
+ */
294
+ public function getTracking($trackings)
295
+ {
296
+ $return = array();
297
+
298
+ if (!is_array($trackings)) {
299
+ $trackings = array($trackings);
300
+ }
301
+
302
+ $this->_getCgiTracking($trackings);
303
+
304
+ return $this->_result;
305
+ }
306
+
307
+ /**
308
+ * Prepare shipment request.
309
+ * Validate and correct request information
310
+ *
311
+ * @param Varien_Object $request
312
+ *
313
+ */
314
+ protected function _prepareShipmentRequest(Varien_Object $request)
315
+ {
316
+ $phonePattern = '/[\s\_\-\(\)]+/';
317
+ $phoneNumber = $request->getShipperContactPhoneNumber();
318
+ $phoneNumber = preg_replace($phonePattern, '', $phoneNumber);
319
+ $request->setShipperContactPhoneNumber($phoneNumber);
320
+ $phoneNumber = $request->getRecipientContactPhoneNumber();
321
+ $phoneNumber = preg_replace($phonePattern, '', $phoneNumber);
322
+ $request->setRecipientContactPhoneNumber($phoneNumber);
323
+ }
324
+
325
+ /**
326
+ * Do request to shipment
327
+ *
328
+ * @param Mage_Shipping_Model_Shipment_Request $request
329
+ * @return array
330
+ */
331
+ public function requestToShipment(Mage_Shipping_Model_Shipment_Request $request)
332
+ {
333
+ $packages = $request->getPackages();
334
+ if (!is_array($packages) || !$packages) {
335
+ Mage::throwException(Mage::helper('usa')->__('No packages for request'));
336
+ }
337
+ if ($request->getStoreId() != null) {
338
+ $this->setStore($request->getStoreId());
339
+ }
340
+ $data = array();
341
+ foreach ($packages as $packageId => $package) {
342
+ $request->setPackageId($packageId);
343
+ $request->setPackagingType($package['params']['container']);
344
+ $request->setPackageWeight($package['params']['weight']);
345
+ $request->setPackageParams(new Varien_Object($package['params']));
346
+ $request->setPackageItems($package['items']);
347
+ $result = $this->_doShipmentRequest($request);
348
+
349
+ if ($result->hasErrors()) {
350
+ $this->rollBack($data);
351
+ break;
352
+ } else {
353
+ $data[] = array(
354
+ 'tracking_number' => $result->getTrackingNumber(),
355
+ 'label_content' => $result->getShippingLabelContent()
356
+ );
357
+ }
358
+ if (!isset($isFirstRequest)) {
359
+ $request->setMasterTrackingId($result->getTrackingNumber());
360
+ $isFirstRequest = false;
361
+ }
362
+ }
363
+
364
+ $response = new Varien_Object(array(
365
+ 'info' => $data
366
+ ));
367
+ if ($result->getErrors()) {
368
+ $response->setErrors($result->getErrors());
369
+ }
370
+ return $response;
371
+ }
372
+
373
+ /**
374
+ * Do request to RMA shipment
375
+ *
376
+ * @param $request
377
+ * @return array
378
+ */
379
+ public function returnOfShipment($request)
380
+ {
381
+ $request->setIsReturn(true);
382
+ $packages = $request->getPackages();
383
+ if (!is_array($packages) || !$packages) {
384
+ Mage::throwException(Mage::helper('usa')->__('No packages for request'));
385
+ }
386
+ if ($request->getStoreId() != null) {
387
+ $this->setStore($request->getStoreId());
388
+ }
389
+ $data = array();
390
+ foreach ($packages as $packageId => $package) {
391
+ $request->setPackageId($packageId);
392
+ $request->setPackagingType($package['params']['container']);
393
+ $request->setPackageWeight($package['params']['weight']);
394
+ $request->setPackageParams(new Varien_Object($package['params']));
395
+ $request->setPackageItems($package['items']);
396
+ $result = $this->_doShipmentRequest($request);
397
+
398
+ if ($result->hasErrors()) {
399
+ $this->rollBack($data);
400
+ break;
401
+ } else {
402
+ $data[] = array(
403
+ 'tracking_number' => $result->getTrackingNumber(),
404
+ 'label_content' => $result->getShippingLabelContent()
405
+ );
406
+ }
407
+ if (!isset($isFirstRequest)) {
408
+ $request->setMasterTrackingId($result->getTrackingNumber());
409
+ $isFirstRequest = false;
410
+ }
411
+ }
412
+
413
+ $response = new Varien_Object(array(
414
+ 'info' => $data
415
+ ));
416
+ if ($result->getErrors()) {
417
+ $response->setErrors($result->getErrors());
418
+ }
419
+ return $response;
420
+ }
421
+
422
+ /**
423
+ * Return container types of carrier
424
+ *
425
+ * @param Varien_Object|null $params
426
+ * @return array
427
+ */
428
+ public function getContainerTypes(Varien_Object $params = null)
429
+ {
430
+ $model = Mage::getModel('carrier/config');
431
+ if($params){
432
+ $collection = $model->getCollection()
433
+ ->addFieldToFilter('config_type',array('eq'=>'packaging'))->addFieldToFilter('apply_to',array('eq'=>$params->getMethod()));
434
+ if($collection){
435
+ $containerTypes = array();
436
+ foreach ($collection as $row){
437
+ $containerTypes[$row->getConfigKey()] = $row->getConfigValue();
438
+ }
439
+ return $containerTypes;
440
+ }else{
441
+ return array();
442
+ }
443
+ }else{
444
+ return $this->_getAllowedContainers($params);
445
+ }
446
+ return array();
447
+ }
448
+
449
+ public function rollBack($data)
450
+ {
451
+ return true;
452
+ }
453
+
454
+ protected function _doShipmentRequest(Varien_Object $request)
455
+ {
456
+ $result = new Varien_Object();
457
+ $_rawShipmentRequest = $this->_collectShipmentRequestData($request);
458
+
459
+ $quoteResult = $this->_sendRequest($this->_quote_path, $_rawShipmentRequest, true);
460
+ if($quoteResult){
461
+ if(isset($quoteResult->ErrorMessage) && $quoteResult->ErrorMessage != 'OK'){
462
+ $result->setErrors($quoteResult->ErrorMessage);
463
+ }else if($quoteResult->Estimator){
464
+ $quoteData = $quoteResult->Estimator[0];
465
+ $quoteID = $quoteData->QuoteID;
466
+ $shipmentResult = $this->_sendRequestShipment($this->_shipment_path. '/' . $quoteID);
467
+
468
+ if($shipmentResult){
469
+ $result->setShippingLabelContent(base64_decode($shipmentResult->LabelImage));
470
+ //$result->setTrackingNumber($shipmentResult->TrackingNumber);
471
+ $result->setTrackingNumber($shipmentResult->InternalTrackingNumber);
472
+
473
+ }else{
474
+ $result->setErrors(Mage::helper('sales')->__('An error occurred while creating shipping label..'));
475
+ }
476
+ }else{
477
+ $result->setErrors(Mage::helper('sales')->__('An error occurred while creating shipping label. Separate your shipment or change the package type.'));
478
+ }
479
+ }
480
+ return $result;
481
+ }
482
+
483
+ private function _collectShipmentRequestData(Varien_Object $request){
484
+ $this->_prepareShipmentRequest($request);
485
+ $contacts = $this->_sendRequest($this->_location_path, array(), false);
486
+ if(!$contacts){
487
+ return null;
488
+ }
489
+ $contactId = $contacts[0]->ContactId;
490
+
491
+ if ($request->getShipperAddressCountryCode() != $request->getRecipientAddressCountryCode()) {
492
+ $IsResidential = false;
493
+ }else{
494
+ $IsResidential = true;
495
+ }
496
+ $packageType = $request->getPackagingType();
497
+
498
+ $CarrierCode = "2";
499
+ $model = Mage::getModel('carrier/config');
500
+ $collection = $model->getCollection()
501
+ ->addFieldToFilter('config_type',array('eq'=>'method'))->addFieldToFilter('config_key',array('eq'=>$request->getShippingMethod()));
502
+ if($collection){
503
+ $Carrier = $collection->getFirstItem()->getCarrier();
504
+ $CarrierData = $model->getCollection()
505
+ ->addFieldToFilter('config_type',array('eq'=>'carrier'))->addFieldToFilter('config_key',array('eq'=>$Carrier));
506
+ if($CarrierData){
507
+ $CarrierCode = $CarrierData->getFirstItem()->getApplyTo();
508
+ }
509
+ }
510
+ $CarrierCode = intval($CarrierCode);
511
+
512
+ $productIds = array();
513
+ $packageParams = $request->getPackageParams();
514
+ $packageItems = $request->getPackageItems();
515
+ $insured = 0;
516
+
517
+ foreach ($packageItems as $itemShipment) {
518
+ $item = new Varien_Object();
519
+ $item->setData($itemShipment);
520
+
521
+ $product = Mage::getModel('catalog/product')->load( $item->getProductId() );
522
+ if ($product->isVirtual() || $product->getParentItem()) {
523
+ continue;
524
+ }
525
+
526
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
527
+ foreach ($item->getChildren() as $child) {
528
+ if (!$child->getProduct()->isVirtual()) {
529
+ $product = Mage::getModel('catalog/product')->load( $item->getProductId() );
530
+ if($product->getInsured()){
531
+ $insured += $product->getInsured() * $item->getQty();
532
+ }else if($product->getCost()){
533
+ $insured += $product->getCost() * $item->getQty();
534
+ }else{
535
+ $insured += $product->getPrice() * $item->getQty();
536
+ }
537
+ }
538
+ }
539
+ } else{
540
+ if($product->getInsured()){
541
+ $insured += $product->getInsured() * $item->getQty();
542
+ }else if($product->getCost()){
543
+ $insured += $product->getCost() * $item->getQty();
544
+ }else{
545
+ $insured += $product->getPrice() * $item->getQty();
546
+ }
547
+ }
548
+ }
549
+
550
+ // get countries of manufacture
551
+ $productCollection = Mage::getResourceModel('catalog/product_collection')
552
+ ->addStoreFilter($request->getStoreId())
553
+ ->addFieldToFilter('entity_id', array('in' => $productIds))
554
+ ->addAttributeToSelect('country_of_manufacture');
555
+ foreach ($productCollection as $product) {
556
+ $countriesOfManufacture[] = $product->getCountryOfManufacture();
557
+ }
558
+
559
+
560
+ if($this->getConfigData('saturday_pickup') == '0'){
561
+ $isSaturdayPickUp = false;
562
+ }else{
563
+ $isSaturdayPickUp = true;
564
+ }
565
+
566
+ if($this->getConfigData('saturday_delivery') == '0'){
567
+ $isSaturdayDelivery = false;
568
+ }else{
569
+ $isSaturdayDelivery = true;
570
+ }
571
+
572
+ if($this->getConfigData('delivery_confirmation') == '0'){
573
+ $isDeliveryConfirmation = false;
574
+ }else{
575
+ $isDeliveryConfirmation = true;
576
+ }
577
+
578
+ if($this->getConfigData('regular_pickup') == '0'){
579
+ $isRegularPickUp = false;
580
+ }else{
581
+ $isRegularPickUp = true;
582
+ }
583
+ if($this->getConfigData('drop_off') == '0'){
584
+ $isDropoff = false;
585
+ }else{
586
+ $isDropoff = true;
587
+ }
588
+ if($this->getConfigData('thermal_label') == '0'){
589
+ $isThermal = false;
590
+ }else{
591
+ $isThermal = true;
592
+ }
593
+
594
+ if($request->getRecipientContactCompanyName()){
595
+ $IsResidential = false;
596
+ }else{
597
+ $IsResidential = true;
598
+ }
599
+ $isDirectSignature = false;
600
+ $deliveryConfirmation = $packageParams->getDeliveryConfirmation();
601
+
602
+ if($deliveryConfirmation == 'ADULT'){
603
+ $isDeliveryConfirmation = true;
604
+ }else if($deliveryConfirmation == 'DIRECT'){
605
+ $isDirectSignature = true;
606
+ }else if($deliveryConfirmation == 'thermal_label'){
607
+ $isThermal = true;
608
+ }
609
+
610
+ if($IsResidential && $CarrierCode == 2){
611
+ $isDirectSignature = true;
612
+ }
613
+
614
+ $requestShipmentData = array(
615
+ "ShipmentId" => "NOID",
616
+ "QuoteId" => "",
617
+ "CustomerId" => "NOID",
618
+ "UserId" => "NOID",
619
+ "ShipToResidential" => $IsResidential,
620
+ "ServiceCode" => $request->getShippingMethod(),
621
+ "CarrierCode" => $CarrierCode,
622
+ "ShipTo" => array(
623
+ "ContactId" => "NOID",
624
+ "CustomerId" => "",
625
+ "UserId" => "",
626
+ "ContactType" => 11,
627
+ "CompanyName" => $request->getRecipientContactCompanyName()."",
628
+ "FirstName" => $request->getRecipientContactPersonFirstName(),
629
+ "LastName" => $request->getRecipientContactPersonLastName(),
630
+ "StreetAddress" => $request->getRecipientAddressStreet1(),
631
+ "ApartmentSuite" => "",
632
+ "ProvinceRegion" => "",
633
+ "City" => $request->getRecipientAddressCity(),
634
+ "State" => $request->getRecipientAddressStateOrProvinceCode(),
635
+ "Country" => $request->getRecipientAddressCountryCode(),
636
+ "Zip" => $request->getRecipientAddressPostalCode(),
637
+ "TelephoneNo" => $request->getRecipientContactPhoneNumber(),
638
+ "FaxNo" => "",
639
+ "Email" => $request->getOrderShipment()->getOrder()->getCustomerEmail(),
640
+ "NickName" => "",
641
+ "IsExpress" => false,
642
+ "IsResidential" => $IsResidential,
643
+ "IsUserDefault" => false,
644
+ "UPSPickUpType" => 0,
645
+ "TotalContacts" => "0"
646
+ ),
647
+ "UpdateAddressBook" => false,
648
+ "NotifyRecipient" => false,
649
+ "ShipFrom" => array(
650
+ "ContactId" => $contactId,
651
+ //"ContactId" => "NOID",
652
+ "CustomerId" => "",
653
+ "UserId" => "",
654
+ "ContactType" => 3,
655
+ "CompanyName" => "",
656
+ "FirstName" => "",
657
+ "LastName" => "",
658
+ "StreetAddress" => "",
659
+ "ApartmentSuite" => "",
660
+ "ProvinceRegion" => "",
661
+ "City" => "",
662
+ "State" => "",
663
+ "Country" => "",
664
+ "Zip" => "",
665
+ "TelephoneNo" => "",
666
+ "FaxNo" => "",
667
+ "Email" => "",
668
+ "NickName" => "",
669
+ "IsExpress" => false,
670
+ "IsResidential" => false,
671
+ "IsUserDefault" => false,
672
+ "UPSPickUpType" => 0,
673
+ "TotalContacts" => "0"
674
+ ),
675
+ "ShipDate" => date("Y-m-d"), //"2014-04-13",
676
+ "PackageCode" => $request->getPackagingType(),
677
+ "Height" => $packageParams->getHeight()?$packageParams->getHeight():0,
678
+ "Width" => $packageParams->getWidth()?$packageParams->getWidth():0,
679
+ "Length" => $packageParams->getLength()?$packageParams->getLength():0,
680
+ "Weight" => $request->getPackageWeight()?floatval($request->getPackageWeight()):0,
681
+ "InsuredValue" => $insured,
682
+ "IsSaturdayPickUp" => $isSaturdayPickUp,
683
+ "IsSaturdayDelivery" => $isSaturdayDelivery,
684
+ "IsDeliveryConfirmation" => $isDeliveryConfirmation,
685
+ //"IsCod" => false,
686
+ //"CodAmount" => 0.0,
687
+ "IsSecuredCod" => false,
688
+ "IsRegularPickUp" => $isRegularPickUp,
689
+ "IsDropoff" => $isDropoff,
690
+ "IsPickUpRequested" => false,
691
+ "IsSmartPickUp" => false,
692
+ "PickUpContactName" => "",
693
+ "PickUpTelephone" => "",
694
+ "PickUpAtHour" => "",
695
+ "PickUpAtMinute" => "",
696
+ "PickUpByHour" => "",
697
+ "PickUpByMinute" => "",
698
+ "PickUpDate" => "",
699
+ "DispatchConfirmationNumber" => "",
700
+ "DispatchLocation" => "",
701
+ "NotifySender" => false,
702
+ "ReferenceNumber" => "",
703
+ "TrackingNumber" => "",
704
+ "CustomerReferenceNumber" => "",
705
+ "IsDirectSignature" => $isDirectSignature,
706
+ "IsThermal" => $isThermal,
707
+ "IsMaxCoverageExceeded" => false,
708
+ "Estimator" => array(
709
+
710
+ ),
711
+ "LabelImage" => null,
712
+ "IsBillToThirdParty" => false,
713
+ "BillToThirdPartyPostalCode" => "",
714
+ "BillToAccount" => "",
715
+ "IsShipFromRestrictedZip" => false,
716
+ "IsShipToRestrictedZip" => false,
717
+ "IsShipToHasRestrictedWords" => false,
718
+ "IsShipFromHasRestrictedWords" => false,
719
+ "IsHighValueShipment" => false,
720
+ "IsHighValueReport" => false,
721
+ "ReceivedBy" => "",
722
+ "ReceivedTime" => "",
723
+ "TotalShipments" => "0"
724
+ );
725
+ //echo json_encode($requestShipmentData);
726
+ return $requestShipmentData;
727
+ }
728
+
729
+ /**
730
+ * Get cgi tracking
731
+ *
732
+ * @param mixed $trackings
733
+ * @return mixed
734
+ */
735
+ protected function _getCgiTracking($trackings)
736
+ {
737
+ //ups no longer support tracking for data streaming version
738
+ //so we can only reply the popup window to ups.
739
+ $result = Mage::getModel('shipping/tracking_result');
740
+ $defaults = $this->getDefaults();
741
+ foreach($trackings as $tracking){
742
+ $status = Mage::getModel('shipping/tracking_result_status');
743
+ $status->setCarrier($this->_code);
744
+ $status->setCarrierTitle($this->getConfigData('title'));
745
+ $status->setTracking($tracking);
746
+ $status->setPopup(1);
747
+ $status->setUrl("http://notify.parcelpro.com/track/$tracking");
748
+ $result->append($status);
749
+ }
750
+
751
+ $this->_result = $result;
752
+ return $result;
753
+ }
754
+
755
+ /**
756
+ * Get result of request
757
+ *
758
+ * @return mixed
759
+ */
760
+ public function getResult()
761
+ {
762
+ return $this->_result;
763
+ }
764
+
765
+ /**
766
+ * Return delivery confirmation types of carrier
767
+ *
768
+ * @param Varien_Object|null $params
769
+ * @return array
770
+ */
771
+ public function getDeliveryConfirmationTypes(Varien_Object $params = null)
772
+ {
773
+ $shipment = Mage::registry('current_shipment');
774
+ if($shipment){
775
+ $order = $shipment->getOrder();
776
+ $model = Mage::getModel('carrier/config');
777
+ $collection = $model->getCollection()
778
+ ->addFieldToFilter('config_type',array('eq'=>'method'))->addFieldToFilter('config_key',array('eq'=>str_replace("parcelpro_", "", $order->getShippingMethod())));
779
+ if($collection){
780
+ if(count($collection) == 1){
781
+ $carrier = $collection;
782
+ }else{
783
+ $carrier = $collection[0];
784
+ }
785
+
786
+ if($carrier->carrier == 'UPS'){
787
+ return array(
788
+ 'NO_SIGNATURE_REQUIRED' => Mage::helper('usa')->__('Not Required'),
789
+ 'ADULT' => Mage::helper('usa')->__('Adult Signature'),
790
+ );
791
+ }else{
792
+ return array(
793
+ 'NO_SIGNATURE_REQUIRED' => Mage::helper('usa')->__('Not Required'),
794
+ 'DIRECT' => Mage::helper('usa')->__('Direct Signature'),
795
+ );
796
+ }
797
+ }else{
798
+ return array(
799
+ 'NO_SIGNATURE_REQUIRED' => Mage::helper('usa')->__('Not Required'),
800
+ 'ADULT' => Mage::helper('usa')->__('Adult Signature'),
801
+ 'DIRECT' => Mage::helper('usa')->__('Direct Signature'),
802
+ );
803
+ }
804
+
805
+ }else{
806
+ return array(
807
+ 'NO_SIGNATURE_REQUIRED' => Mage::helper('usa')->__('Not Required'),
808
+ 'ADULT' => Mage::helper('usa')->__('Adult Signature'),
809
+ 'DIRECT' => Mage::helper('usa')->__('Direct Signature'),
810
+ );
811
+ }
812
+ }
813
+
814
+ /**
815
+ * Get configuration data of carrier
816
+ *
817
+ * @param string $type
818
+ * @param string $code
819
+ * @return array|bool
820
+ */
821
+ public function getCode($type, $carrier='')
822
+ {
823
+ /*
824
+ $codes = array(
825
+ 'method' => array(
826
+ '01' => Mage::helper('usa')->__('Next Day Air'),
827
+ '02' => Mage::helper('usa')->__('2nd Day Air'),
828
+ '01-INT' => Mage::helper('usa')->__('International Priority'),
829
+ '01-DOM' => Mage::helper('usa')->__('Priority Overnight'),
830
+ '03-DOM' => Mage::helper('usa')->__('2 Day'),
831
+ '05' => Mage::helper('usa')->__('Standard Overnight'),
832
+ ),
833
+ 'dropoff' => array(
834
+ 'REGULAR_PICKUP' => Mage::helper('usa')->__('Regular Pickup'),
835
+ 'REQUEST_COURIER' => Mage::helper('usa')->__('Request Courier'),
836
+ 'DROP_BOX' => Mage::helper('usa')->__('Drop Box'),
837
+ 'BUSINESS_SERVICE_CENTER' => Mage::helper('usa')->__('Business Service Center'),
838
+ 'STATION' => Mage::helper('usa')->__('Station')
839
+ ),
840
+ 'packaging' => array(
841
+ '25' => Mage::helper('usa')->__('10KG BOX'),
842
+ '24' => Mage::helper('usa')->__('25KG BOX'),
843
+ '21' => Mage::helper('usa')->__('EXPRESS BOX'),
844
+ '01' => Mage::helper('usa')->__('LETTER'),
845
+ '04' => Mage::helper('usa')->__('PAK'),
846
+ '03' => Mage::helper('usa')->__('TUBE'),
847
+ 'LARGE BOX' => Mage::helper('usa')->__('LARGE FEDEX BOX'),
848
+ 'MEDIUM BOX' => Mage::helper('usa')->__('MEDIUM FEDEX BOX'),
849
+ 'SMALL BOX' => Mage::helper('usa')->__('SMALL FEDEX BOX'),
850
+ '02' => Mage::helper('usa')->__('Your Packaging...')
851
+ ),
852
+ 'containers_filter' => array(
853
+ array(
854
+ 'containers' => array('FEDEX_ENVELOPE', 'FEDEX_PAK'),
855
+ 'filters' => array(
856
+ 'within_us' => array(
857
+ 'method' => array(
858
+ 'FEDEX_EXPRESS_SAVER',
859
+ 'FEDEX_2_DAY',
860
+ 'FEDEX_2_DAY_AM',
861
+ 'STANDARD_OVERNIGHT',
862
+ 'PRIORITY_OVERNIGHT',
863
+ 'FIRST_OVERNIGHT',
864
+ )
865
+ ),
866
+ 'from_us' => array(
867
+ 'method' => array(
868
+ 'INTERNATIONAL_FIRST',
869
+ 'INTERNATIONAL_ECONOMY',
870
+ 'INTERNATIONAL_PRIORITY',
871
+ )
872
+ )
873
+ )
874
+ ),
875
+ array(
876
+ 'containers' => array('FEDEX_BOX', 'FEDEX_TUBE'),
877
+ 'filters' => array(
878
+ 'within_us' => array(
879
+ 'method' => array(
880
+ 'FEDEX_2_DAY',
881
+ 'FEDEX_2_DAY_AM',
882
+ 'STANDARD_OVERNIGHT',
883
+ 'PRIORITY_OVERNIGHT',
884
+ 'FIRST_OVERNIGHT',
885
+ 'FEDEX_FREIGHT',
886
+ 'FEDEX_1_DAY_FREIGHT',
887
+ 'FEDEX_2_DAY_FREIGHT',
888
+ 'FEDEX_3_DAY_FREIGHT',
889
+ 'FEDEX_NATIONAL_FREIGHT',
890
+ )
891
+ ),
892
+ 'from_us' => array(
893
+ 'method' => array(
894
+ 'INTERNATIONAL_FIRST',
895
+ 'INTERNATIONAL_ECONOMY',
896
+ 'INTERNATIONAL_PRIORITY',
897
+ )
898
+ )
899
+ )
900
+ ),
901
+ array(
902
+ 'containers' => array('FEDEX_10KG_BOX', 'FEDEX_25KG_BOX'),
903
+ 'filters' => array(
904
+ 'within_us' => array(),
905
+ 'from_us' => array('method' => array('INTERNATIONAL_PRIORITY'))
906
+ )
907
+ ),
908
+ array(
909
+ 'containers' => array('YOUR_PACKAGING'),
910
+ 'filters' => array(
911
+ 'within_us' => array(
912
+ 'method' =>array(
913
+ 'FEDEX_GROUND',
914
+ 'GROUND_HOME_DELIVERY',
915
+ 'SMART_POST',
916
+ 'FEDEX_EXPRESS_SAVER',
917
+ 'FEDEX_2_DAY',
918
+ 'FEDEX_2_DAY_AM',
919
+ 'STANDARD_OVERNIGHT',
920
+ 'PRIORITY_OVERNIGHT',
921
+ 'FIRST_OVERNIGHT',
922
+ 'FEDEX_FREIGHT',
923
+ 'FEDEX_1_DAY_FREIGHT',
924
+ 'FEDEX_2_DAY_FREIGHT',
925
+ 'FEDEX_3_DAY_FREIGHT',
926
+ 'FEDEX_NATIONAL_FREIGHT',
927
+ )
928
+ ),
929
+ 'from_us' => array(
930
+ 'method' =>array(
931
+ 'INTERNATIONAL_FIRST',
932
+ 'INTERNATIONAL_ECONOMY',
933
+ 'INTERNATIONAL_PRIORITY',
934
+ 'INTERNATIONAL_GROUND',
935
+ 'FEDEX_FREIGHT',
936
+ 'FEDEX_1_DAY_FREIGHT',
937
+ 'FEDEX_2_DAY_FREIGHT',
938
+ 'FEDEX_3_DAY_FREIGHT',
939
+ 'FEDEX_NATIONAL_FREIGHT',
940
+ 'INTERNATIONAL_ECONOMY_FREIGHT',
941
+ 'INTERNATIONAL_PRIORITY_FREIGHT',
942
+ )
943
+ )
944
+ )
945
+ )
946
+ ),
947
+
948
+ 'delivery_confirmation_types' => array(
949
+ 'NO_SIGNATURE_REQUIRED' => Mage::helper('usa')->__('Not Required'),
950
+ 'ADULT' => Mage::helper('usa')->__('Adult'),
951
+ 'DIRECT' => Mage::helper('usa')->__('Direct'),
952
+ 'INDIRECT' => Mage::helper('usa')->__('Indirect'),
953
+ ),
954
+
955
+ 'unit_of_measure'=>array(
956
+ 'LB' => Mage::helper('usa')->__('Pounds'),
957
+ 'KG' => Mage::helper('usa')->__('Kilograms'),
958
+ ),
959
+ );
960
+ */
961
+ $model = Mage::getModel('carrier/config');
962
+ if($carrier){
963
+ $collection = $model->getCollection()
964
+ ->addFieldToFilter('config_type',array('eq'=>$type))->addFieldToFilter('carrier',array('eq'=>$carrier));
965
+ }else{
966
+ $collection = $model->getCollection()
967
+ ->addFieldToFilter('config_type',array('eq'=>$type));
968
+ }
969
+ if($collection){
970
+ $data = array();
971
+ foreach ($collection as $row){
972
+ $data[$row->getConfigKey()] = $row->getConfigValue();
973
+ }
974
+ return $data;
975
+ }else{
976
+ return null;
977
+ }
978
+
979
+ }
980
+ private function _parseShippingRates($estimatorData){
981
+ if(!isset( $estimatorData->Estimator)){
982
+ return null;
983
+ }
984
+
985
+ $allowed_carriers = explode(',', strtoupper($this->getConfigData('allowed_carriers')));
986
+ $estimatorList = $estimatorData->Estimator;
987
+ if($estimatorList){
988
+ $allowedMethods = $this->getAllowedMethods();
989
+ if($allowedMethods){
990
+ $alloewdMethodIds = array();
991
+
992
+ foreach ($allowedMethods as $key => $val){
993
+ $alloewdMethodIds[] = $key;
994
+ }
995
+
996
+ $rateList = array();
997
+ foreach ($estimatorList as $estimator){
998
+ if(in_array($estimator->ServiceCode, $alloewdMethodIds) && in_array(strtoupper($estimator->CarrierCode), $allowed_carriers) ){
999
+ $rate = Mage::getModel('shipping/rate_result_method');
1000
+ /* @var $rate Mage_Shipping_Model_Rate_Result_Method */
1001
+
1002
+ $rate->setCarrier($this->_code);
1003
+ $rate->setCarrierTitle($this->getConfigData('title'));
1004
+
1005
+ $rate->setMethod($estimator->ServiceCode);
1006
+ $rate->setMethodTitle($estimator->ServiceCodeDescription);
1007
+
1008
+ $rate->setPrice($estimator->TotalCharges);
1009
+ $rate->setCost($estimator->AccessorialsCost);
1010
+
1011
+ $rateList[] = $rate;
1012
+ }
1013
+ }
1014
+ return $rateList;
1015
+ }else{
1016
+ return null;
1017
+ }
1018
+ }else{
1019
+ return null;
1020
+ }
1021
+ }
1022
+
1023
+ private function _collectRequestData($request){
1024
+ //Mage::log($request->debug());
1025
+ $_rawRequest = array();
1026
+
1027
+ $insured = 0;
1028
+ if ($request->getAllItems()) {
1029
+ foreach ($request->getAllItems() as $item) {
1030
+ $product = Mage::getModel('catalog/product')->load( $item->getProductId() );
1031
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
1032
+ continue;
1033
+ }
1034
+
1035
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
1036
+ foreach ($item->getChildren() as $child) {
1037
+ if (!$child->getProduct()->isVirtual()) {
1038
+ $product = Mage::getModel('catalog/product')->load( $item->getProductId() );
1039
+ if($product->getInsured()){
1040
+ $insured += $product->getInsured() * $item->getQty();
1041
+ }else if($product->getCost()){
1042
+ $insured += $product->getCost() * $item->getQty();
1043
+ }else{
1044
+ $insured += $product->getPrice() * $item->getQty();
1045
+ }
1046
+ }
1047
+ }
1048
+ } else{
1049
+ if($product->getInsured()){
1050
+ $insured += $product->getInsured() * $item->getQty();
1051
+ }else if($product->getCost()){
1052
+ $insured += $product->getCost() * $item->getQty();
1053
+ }else{
1054
+ $insured += $product->getPrice() * $item->getQty();
1055
+ }
1056
+ }
1057
+ }
1058
+ }
1059
+
1060
+ $user = $this->_sendRequest($this->_user_path, array(), false);
1061
+ $contactId = $user->DefaultLocation;
1062
+
1063
+ if($this->getConfigData('saturday_pickup') == '0'){
1064
+ $isSaturdayPickUp = false;
1065
+ }else{
1066
+ $isSaturdayPickUp = true;
1067
+ }
1068
+
1069
+ if($this->getConfigData('saturday_delivery') == '0'){
1070
+ $isSaturdayDelivery = false;
1071
+ }else{
1072
+ $isSaturdayDelivery = true;
1073
+ }
1074
+
1075
+ if($this->getConfigData('delivery_confirmation') == '0'){
1076
+ $isDeliveryConfirmation = false;
1077
+ }else{
1078
+ $isDeliveryConfirmation = true;
1079
+ }
1080
+
1081
+ if($this->getConfigData('regular_pickup') == '0'){
1082
+ $isRegularPickUp = false;
1083
+ }else{
1084
+ $isRegularPickUp = true;
1085
+ }
1086
+ if($this->getConfigData('drop_off') == '0'){
1087
+ $isDropoff = false;
1088
+ }else{
1089
+ $isDropoff = true;
1090
+ }
1091
+
1092
+ $_rawRequest = array(
1093
+ //"ShipToResidential" => false,
1094
+ "ShipTo" => array(
1095
+ "ContactId" => "NOID",
1096
+ "CustomerId" => "",
1097
+ "UserId" => "",
1098
+ "ContactType" =>3,
1099
+ "CompanyName" => "",
1100
+ "FirstName" => "",
1101
+ "LastName" => "",
1102
+ "StreetAddress" => $request->getDestStreet()?$request->getDestStreet(): "",
1103
+ "ApartmentSuite" => "",
1104
+ "ProvinceRegion" => $request->getDestRegionCode()?$request->getDestRegionCode():"",
1105
+ "City" => $request->getDestCity()?$request->getDestCity():"",
1106
+ "State" => $request->getDestRegionCode()?$request->getDestRegionCode():"",
1107
+ "Country" => $request->getDestCountryId(),
1108
+ "Zip" => $request->getDestPostcode(),
1109
+ "TelephoneNo" => '',
1110
+ "FaxNo" => "",
1111
+ "Email" => "",
1112
+ "NickName" => "",
1113
+ "IsExpress" => false,
1114
+ "IsResidential" => false,
1115
+ "IsUserDefault" =>false,
1116
+ "UPSPickUpType" => 0,
1117
+ "TotalContacts" => "0"
1118
+ ),
1119
+ "ShipFrom" => array(
1120
+ //"ContactId" => "NOID",
1121
+ "ContactId" => $contactId,
1122
+ "CustomerId" => "",
1123
+ "UserId" => "",
1124
+ "ContactType" => 3,
1125
+ "CompanyName" => "",
1126
+ "FirstName" => "",
1127
+ "LastName" => "",
1128
+ "StreetAddress" => "",
1129
+ "ApartmentSuite" => "",
1130
+ "ProvinceRegion" => "",
1131
+ "City" => "",
1132
+ "State" => "",
1133
+ "Country" => "",
1134
+ "Zip" => "",
1135
+ "TelephoneNo" => "",
1136
+ "FaxNo" => "",
1137
+ "Email" => "",
1138
+ "NickName" => "",
1139
+ "IsExpress" => false,
1140
+ "IsResidential" => false,
1141
+ "IsUserDefault" => false,
1142
+ "UPSPickUpType" => 0,
1143
+ "TotalContacts" => "0"
1144
+ ),
1145
+ "Height" => $request->getPackageHeight()?$request->getPackageHeight(): 0,
1146
+ "Width" => $request->getPackageWidth()?$request->getPackageWidth():0,
1147
+ "Length" => $request->getPackageDepth()?$request->getPackageDepth():0,
1148
+ "Weight" => $request->getPackageWeight()?$request->getPackageWeight():0,
1149
+ "InsuredValue" => $insured,
1150
+ "IsSaturdayPickUp" => $isSaturdayPickUp,
1151
+ "IsSaturdayDelivery" => $isSaturdayDelivery,
1152
+ "IsDeliveryConfirmation" => $isDeliveryConfirmation,
1153
+ //"IsCod" => false,
1154
+ //"CodAmount" => 0.0,
1155
+ "PackageCode" => $this->getConfigData('packaging'),
1156
+ "IsSecuredCod" => false,
1157
+ "IsRegularPickUp" => $isRegularPickUp,
1158
+ "IsDropoff" => $isDropoff,
1159
+ );
1160
+ //Mage::log(json_encode($_rawRequest));
1161
+ return $_rawRequest;
1162
+ }
1163
+
1164
+ private function _sendRequestShipment($requestPath){
1165
+ if(!$this->_sessionId){
1166
+ $this->_getSessionId();
1167
+ }
1168
+
1169
+ if($this->_sessionId){
1170
+ $url = $this->_base_url . $this->_version . $requestPath . '?sessionID=' . $this->_sessionId;
1171
+ $ch = curl_init();
1172
+ curl_setopt($ch, CURLOPT_URL, $url);
1173
+ curl_setopt($ch, CURLOPT_POST, 1);
1174
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1175
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1176
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
1177
+ 'Content-Type: application/xml',
1178
+ 'Content-Length: 0'
1179
+ )
1180
+ );
1181
+
1182
+ $data = curl_exec ($ch);
1183
+ curl_close ($ch);
1184
+ if($data){
1185
+ $result = json_encode(simplexml_load_string($data));
1186
+ return json_decode($result, false);
1187
+ }else{
1188
+ return null;
1189
+ }
1190
+ }else{
1191
+ return null;
1192
+ }
1193
+ }
1194
+ private function _sendRequest($requestPath, $parrams, $isPost = false){
1195
+ if(!$this->_sessionId){
1196
+ $this->_getSessionId();
1197
+ }
1198
+
1199
+ if($this->_sessionId){
1200
+ $url = $this->_base_url . $this->_version . $requestPath . '?sessionID=' . $this->_sessionId;
1201
+ $ch = curl_init();
1202
+ curl_setopt($ch, CURLOPT_URL, $url);
1203
+ if($isPost){
1204
+ curl_setopt($ch, CURLOPT_POST, 1);
1205
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($parrams));
1206
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
1207
+ 'Content-Type: application/json',
1208
+ 'Content-Length: ' . strlen(json_encode($parrams)))
1209
+ );
1210
+ }else{
1211
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
1212
+ 'Content-Type: application/json',
1213
+ )
1214
+ );
1215
+ }
1216
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1217
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1218
+ curl_setopt($ch, CURLOPT_HEADER, true);
1219
+
1220
+ $data = curl_exec ($ch);
1221
+ list($header,$data) = explode("\r\n\r\n",$data,2);
1222
+ $header = explode("\r\n",$header);
1223
+ $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
1224
+ curl_close ($ch);
1225
+ if($http_status == '400'){
1226
+ Mage::log("Query failed:".explode(" ",$header[0])[3],null,'ppimagento.log');
1227
+ }
1228
+ if($data){
1229
+ if($requestPath == $this->_quote_path){
1230
+ //echo $url;
1231
+ //echo $data;
1232
+ //var_dump($data);
1233
+ }
1234
+ if($isPost){
1235
+ $result = json_decode($data);
1236
+ }else{
1237
+ $result = json_decode($data);
1238
+ }
1239
+ return $result;
1240
+ }else{
1241
+ return null;
1242
+ }
1243
+ }else{
1244
+ return null;
1245
+ }
1246
+ }
1247
+ private function _getSessionId(){
1248
+ $model = Mage::getModel('carrier/config');
1249
+ $collection = $model->getCollection()
1250
+ ->addFieldToFilter('config_type',array('eq'=>'session_id'));
1251
+ if($collection->count()){
1252
+ $item = $collection->getFirstItem();
1253
+ if($this->_checkInvalideSession($item->getConfigValue())){
1254
+ $this->_sessionId = $item->getConfigValue();
1255
+ return $item->getConfigValue();
1256
+ }else{
1257
+ $item->delete();
1258
+ }
1259
+ }
1260
+
1261
+ $username = Mage::helper('core')->decrypt($this->getConfigData('account'));
1262
+ $password = Mage::helper('core')->decrypt($this->getConfigData('password'));
1263
+ $apikey = Mage::helper('core')->decrypt($this->getConfigData('key'));
1264
+
1265
+ $ch = curl_init();
1266
+ $auth_url = $this->_base_url . $this->_version . $this->_auth_path;
1267
+ $auth_url .= '?username='.$username.'&password='.$password.'&apikey='.$apikey;
1268
+
1269
+ curl_setopt($ch, CURLOPT_URL, $auth_url);
1270
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1271
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1272
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
1273
+ 'Content-Type: application/json',
1274
+ )
1275
+ );
1276
+
1277
+ $authData = curl_exec ($ch);
1278
+ curl_close ($ch);
1279
+ if($authData){
1280
+ $result = json_decode($authData);
1281
+ $this->_sessionId = $result->SessionID;
1282
+ $this->_checkInvalideSession($result->SessionID);
1283
+
1284
+ $model->setCarrier("")
1285
+ ->setConfigType('session_id')
1286
+ ->setConfigKey('session_id')
1287
+ ->setConfigValue($result->SessionID)
1288
+ ->save();
1289
+ $model->unsetData();
1290
+
1291
+ return $result->SessionID;
1292
+ }else{
1293
+ return false;
1294
+ }
1295
+ }
1296
+
1297
+ private function _checkInvalideSession($sessionId){
1298
+ if($sessionId == null || $sessionId == ""){
1299
+ return false;
1300
+ }
1301
+ $ch = curl_init();
1302
+ $location_url = $this->_base_url . $this->_version . $this->_location_path;
1303
+ $location_url .= '?sessionID=' . $sessionId;
1304
+
1305
+ curl_setopt($ch, CURLOPT_URL, $location_url);
1306
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1307
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
1308
+ $locationData = curl_exec ($ch);
1309
+ $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
1310
+ curl_close ($ch);
1311
+ if($http_status == '401'){
1312
+ return false;
1313
+ }else{
1314
+ return true;
1315
+ }
1316
+ }
1317
+ }
app/code/community/ParcelPro/Carrier/Model/Config.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ParcelPro_Carrier_Model_Config extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('carrier/config');
9
+ }
10
+
11
+ public function deleteProduct($wholedata){
12
+ $id = explode('/id/',$wholedata );
13
+ Mage::register("isSecureArea", 1);
14
+ Mage :: app("default") -> setCurrentStore( Mage_Core_Model_App :: ADMIN_STORE_ID );
15
+ Mage::getModel('catalog/product')->load($id[1])->delete();
16
+ $collection=Mage::getModel('marketplace/product')->getCollection()
17
+ ->addFieldToFilter('mageproductid',array('eq'=>$id[1]));
18
+ foreach($collection as $row){
19
+ $row->delete();
20
+ }
21
+ return 0;
22
+ }
23
+ }
app/code/community/ParcelPro/Carrier/Model/Mysql4/Config.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ParcelPro_Carrier_Model_Mysql4_Config extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('carrier/config', 'index_id');
7
+ }
8
+ }
app/code/community/ParcelPro/Carrier/Model/Mysql4/Config/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ParcelPro_Carrier_Model_Mysql4_Config_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('carrier/config');
8
+ }
9
+ }
app/code/community/ParcelPro/Carrier/Model/Resource/Mysql4/Setup.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ class ParcelPro_Carrier_Model_Resource_Mysql4_Setup extends Mage_Catalog_Model_Resource_Setup {
3
+ }
app/code/community/ParcelPro/Carrier/Model/Source/Carriers.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ * @category Mage
5
+ * @package ParcelPro_Carrier
6
+ * @copyright Copyright (c) 2013 ParcelPro Inc. (http://www.magentocommerce.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ /**
11
+ * Fedex method source implementation
12
+ *
13
+ * @category Mage
14
+ * @package Mage_Usa
15
+ * @author Magento Core Team <core@magentocommerce.com>
16
+ */
17
+ class ParcelPro_Carrier_Model_Source_Carriers
18
+ {
19
+ public function toOptionArray()
20
+ {
21
+ $parcelPro = Mage::getSingleton('carrier/carrier');
22
+ $arr = array();
23
+ foreach ($parcelPro->getCode('carrier') as $k => $v) {
24
+ $arr[] = array('value' => $k, 'label' => $v);
25
+ }
26
+ return $arr;
27
+ }
28
+ }
app/code/community/ParcelPro/Carrier/Model/Source/Dropoff.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Fedex dropoff source implementation
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Usa
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Usa_Model_Shipping_Carrier_Fedex_Source_Dropoff
35
+ {
36
+ public function toOptionArray()
37
+ {
38
+ $fedex = Mage::getSingleton('usa/shipping_carrier_fedex');
39
+ $arr = array();
40
+ foreach ($fedex->getCode('dropoff') as $k => $v) {
41
+ $arr[] = array('value' => $k, 'label' => $v);
42
+ }
43
+ return $arr;
44
+ }
45
+ }
app/code/community/ParcelPro/Carrier/Model/Source/Fedexmethod.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ * @category Mage
5
+ * @package ParcelPro_Carrier
6
+ * @copyright Copyright (c) 2013 ParcelPro Inc. (http://www.magentocommerce.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ /**
11
+ * Fedex method source implementation
12
+ *
13
+ * @category Mage
14
+ * @package Mage_Usa
15
+ * @author Magento Core Team <core@magentocommerce.com>
16
+ */
17
+ class ParcelPro_Carrier_Model_Source_Fedexmethod
18
+ {
19
+ public function toOptionArray()
20
+ {
21
+ $parcelPro = Mage::getSingleton('carrier/carrier');
22
+ $arr = array();
23
+ foreach ($parcelPro->getCode('method', 'FEDEX') as $k => $v) {
24
+ $arr[] = array('value' => $k, 'label' => $v);
25
+ }
26
+ return $arr;
27
+ }
28
+ }
app/code/community/ParcelPro/Carrier/Model/Source/Freemethod.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Fedex freemethod source implementation
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Usa
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class ParcelPro_Carrier_Model_Source_Freemethod
35
+ {
36
+ public function toOptionArray()
37
+ {
38
+ $parcelPro = Mage::getSingleton('carrier/carrier');
39
+ $arr = array();
40
+ foreach ($parcelPro->getCode('method') as $k => $v) {
41
+ $arr[] = array('value' => $k, 'label' => $v);
42
+ }
43
+ return $arr;
44
+ }
45
+ }
app/code/community/ParcelPro/Carrier/Model/Source/Packaging.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Fedex packaging source implementation
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Usa
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class ParcelPro_Carrier_Model_Source_Packaging
35
+ {
36
+ public function toOptionArray()
37
+ {
38
+ $parcelPro = Mage::getSingleton('carrier/carrier');
39
+ $arr = array();
40
+ foreach ($parcelPro->getCode('packaging') as $k => $v) {
41
+ $arr[] = array('value' => $k, 'label' => $v);
42
+ }
43
+ return $arr;
44
+ }
45
+ }
app/code/community/ParcelPro/Carrier/Model/Source/Unitofmeasure.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ * @category Mage
5
+ * @package Mage_Usa
6
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ /**
11
+ * Fedex packaging source implementation
12
+ *
13
+ * @category Mage
14
+ * @package Mage_Usa
15
+ * @author Magento Core Team <core@magentocommerce.com>
16
+ */
17
+ class ParcelPro_Carrier_Model_Source_Unitofmeasure
18
+ {
19
+ /**
20
+ * Return array of Measure units
21
+ *
22
+ * @return array
23
+ */
24
+ public function toOptionArray()
25
+ {
26
+ $measureUnits = Mage::getSingleton('carrier/carrier')->getCode('unit_of_measure');
27
+ $result = array();
28
+ foreach ($measureUnits as $key => $val){
29
+ $result[] = array('value'=>$key,'label'=>$val);
30
+ }
31
+ return $result;
32
+ }
33
+ }
app/code/community/ParcelPro/Carrier/Model/Source/Upsmethod.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+
4
+ * @category Mage
5
+ * @package ParcelPro_Carrier
6
+ * @copyright Copyright (c) 2013 ParcelPro Inc. (http://www.magentocommerce.com)
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+
10
+ /**
11
+ * Fedex method source implementation
12
+ *
13
+ * @category Mage
14
+ * @package Mage_Usa
15
+ * @author Magento Core Team <core@magentocommerce.com>
16
+ */
17
+ class ParcelPro_Carrier_Model_Source_Upsmethod
18
+ {
19
+ public function toOptionArray()
20
+ {
21
+ $parcelPro = Mage::getSingleton('carrier/carrier');
22
+ $arr = array();
23
+ $methods = $parcelPro->getCode('method', 'UPS');
24
+ if($methods){
25
+ foreach ($methods as $k => $v) {
26
+ $arr[] = array('value' => $k, 'label' => $v);
27
+ }
28
+ }
29
+ return $arr;
30
+ }
31
+ }
app/code/community/ParcelPro/Carrier/controllers/Adminhtml/RefreshController.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ParcelPro_Carrier_Adminhtml_RefreshController extends Mage_Adminhtml_Controller_Action {
3
+ public function indexAction() {
4
+ $this->getResponse ()->setRedirect ( $this->getUrl ( "admi\x6e\150\164\x6d\154\x2f\163\171\x73t\145\155_\x63\x6f\156\x66i\147\x2fe\144\x69\x74\057\x73\145c\x74i\157\x6e\x2f\x75\154\x74\151\155\157/" ) );
5
+ }
6
+ public function refreshAction() {
7
+ $parcelProHelper = Mage::helper ( 'carrier/parcelpro' );
8
+ $parcelProHelper->updateCarriers();
9
+ $parcelProHelper->updateCarrierServices();
10
+ $parcelProHelper->updatePackageTypes();
11
+ $parcelProHelper->updateSpecialServices();
12
+
13
+ $this->getResponse ()->setRedirect ( $this->getUrl ( "adminhtml/system_config/edit/section/carriers" ) );
14
+ }
15
+ }
app/code/community/ParcelPro/Carrier/controllers/IndexController.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ParcelPro_Carrier_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+ }
app/code/community/ParcelPro/Carrier/etc/config.xml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <ParcelPro_Carrier>
5
+ <version>1.0.0</version>
6
+ </ParcelPro_Carrier>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <carrier>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>ParcelPro_Carrier</module>
14
+ <frontName>parcelpro_carrier</frontName>
15
+ </args>
16
+ </carrier>
17
+ </routers>
18
+ </admin>
19
+ <global>
20
+ <blocks>
21
+ <carrier>
22
+ <class>ParcelPro_Carrier_Block</class>
23
+ </carrier>
24
+ </blocks>
25
+ <helpers>
26
+ <carrier>
27
+ <class>ParcelPro_Carrier_Helper</class>
28
+ </carrier>
29
+ </helpers>
30
+ <models>
31
+ <carrier>
32
+ <class>ParcelPro_Carrier_Model</class>
33
+ <resourceModel>carrier_mysql4</resourceModel>
34
+ </carrier>
35
+ <carrier_mysql4>
36
+ <class>ParcelPro_Carrier_Model_Mysql4</class>
37
+ <entities>
38
+ <config>
39
+ <table>parcelpro_carrier_config</table>
40
+ </config>
41
+ </entities>
42
+ </carrier_mysql4>
43
+ </models>
44
+ <resources>
45
+ <carrier_setup>
46
+ <setup>
47
+ <module>ParcelPro_Carrier</module>
48
+ <class>ParcelPro_Carrier_Model_Resource_Mysql4_Setup</class>
49
+ </setup>
50
+ <connection>
51
+ <use>core_setup</use>
52
+ </connection>
53
+ </carrier_setup>
54
+ <carrier_write>
55
+ <connection>
56
+ <use>core_write</use>
57
+ </connection>
58
+ </carrier_write>
59
+ <carrier_read>
60
+ <connection>
61
+ <use>core_read</use>
62
+ </connection>
63
+ </carrier_read>
64
+ </resources>
65
+ <!--
66
+ <sales>
67
+ <quote>
68
+ <item>
69
+ <product_attributes>
70
+ <insured/>
71
+ </product_attributes>
72
+ </item>
73
+ </quote>
74
+ </sales>
75
+ -->
76
+ </global>
77
+ <!-- Default configuration -->
78
+ <default>
79
+ <carriers>
80
+ <parcelpro>
81
+ <active>1</active>
82
+ <!--
83
+ This configuration should not be made visible
84
+ to the administrator, because it specifies
85
+ the model to be used for this carrier.
86
+ -->
87
+ <model>carrier/carrier</model>
88
+ <!--
89
+ The title as referenced in the carrier class
90
+ -->
91
+ <title>Parcel Pro</title>
92
+ <!--
93
+ The sort order specifies the position that
94
+ this carrier appears relative to the other
95
+ carriers available in checkout.
96
+ -->
97
+ <sort_order>10</sort_order>
98
+ <!--
99
+ Out of the box, Magento offers shipping
100
+ carriers the ability to restrict themselves
101
+ to specific countries. For this configuration
102
+ option, 0 means allow all countries available,
103
+ and 1 means allow all countries specified
104
+ in the country list that we will add later
105
+ in system.xml
106
+ -->
107
+ <sallowspecific>0</sallowspecific>
108
+ </parcelpro>
109
+ </carriers>
110
+ </default>
111
+ </config>
app/code/community/ParcelPro/Carrier/etc/system.xml ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Usa
24
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <sections>
30
+ <carriers>
31
+ <groups>
32
+ <parcelpro translate="label" module="shipping">
33
+ <label>Parcel Pro</label>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>120</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ <fields>
40
+ <active translate="label">
41
+ <label>Enabled for Checkout</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <sort_order>10</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>0</show_in_store>
48
+ </active>
49
+ <refresh translate="label">
50
+ <label></label>
51
+ <comment>
52
+ <![CDATA[Click this button to get newest data from providers.]]>
53
+ </comment>
54
+ <frontend_type>button</frontend_type>
55
+ <frontend_model>carrier/adminhtml_button_refresh_cms</frontend_model>
56
+ <process>refresh</process>
57
+ <sort_order>15</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>1</show_in_store>
61
+ </refresh>
62
+ <title translate="label">
63
+ <label>Title</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>20</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </title>
70
+ <account translate="label comment">
71
+ <label>Account ID</label>
72
+ <frontend_type>obscure</frontend_type>
73
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
74
+ <sort_order>40</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>0</show_in_store>
78
+ <comment>Please make sure to use only digits here. Dashes are allowed.</comment>
79
+ </account>
80
+ <!--
81
+ <meter_number translate="label">
82
+ <label>Meter Number</label>
83
+ <frontend_type>obscure</frontend_type>
84
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
85
+ <sort_order>50</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>0</show_in_store>
89
+ </meter_number>
90
+ -->
91
+ <key translate="label">
92
+ <label>API Key</label>
93
+ <frontend_type>obscure</frontend_type>
94
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
95
+ <sort_order>60</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>0</show_in_store>
99
+ </key>
100
+ <password translate="label">
101
+ <label>Password</label>
102
+ <frontend_type>obscure</frontend_type>
103
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
104
+ <sort_order>70</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>0</show_in_store>
108
+ </password>
109
+ <allowed_carriers translate="label">
110
+ <label>Allowed Carriers</label>
111
+ <frontend_type>multiselect</frontend_type>
112
+ <source_model>carrier/source_carriers</source_model>
113
+ <sort_order>71</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>0</show_in_store>
117
+ <can_be_empty>0</can_be_empty>
118
+ </allowed_carriers>
119
+ <sandbox_mode translate="label">
120
+ <label>Sandbox Mode</label>
121
+ <frontend_type>select</frontend_type>
122
+ <source_model>adminhtml/system_config_source_yesno</source_model>
123
+ <sort_order>75</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>0</show_in_store>
127
+ </sandbox_mode>
128
+ <packaging translate="label">
129
+ <label>Packaging</label>
130
+ <frontend_type>select</frontend_type>
131
+ <source_model>carrier/source_packaging</source_model>
132
+ <sort_order>80</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>0</show_in_store>
136
+ </packaging>
137
+ <!--
138
+ <dropoff translate="label">
139
+ <label>Dropoff</label>
140
+ <frontend_type>select</frontend_type>
141
+ <source_model>usa/shipping_carrier_fedex_source_dropoff</source_model>
142
+ <sort_order>90</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>0</show_in_store>
146
+ </dropoff>
147
+ -->
148
+ <handling_type translate="label">
149
+ <label>Calculate Handling Fee</label>
150
+ <frontend_type>select</frontend_type>
151
+ <source_model>shipping/source_handlingType</source_model>
152
+ <sort_order>110</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ </handling_type>
157
+ <handling_action translate="label">
158
+ <label>Handling Applied</label>
159
+ <frontend_type>select</frontend_type>
160
+ <source_model>shipping/source_handlingAction</source_model>
161
+ <sort_order>120</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>0</show_in_store>
165
+ </handling_action>
166
+ <handling_fee translate="label">
167
+ <label>Handling Fee</label>
168
+ <frontend_type>text</frontend_type>
169
+ <validate>validate-number validate-zero-or-greater</validate>
170
+ <sort_order>130</sort_order>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>0</show_in_store>
174
+ </handling_fee>
175
+ <residence_delivery translate="label">
176
+ <label>Residential Delivery</label>
177
+ <frontend_type>select</frontend_type>
178
+ <sort_order>140</sort_order>
179
+ <source_model>adminhtml/system_config_source_yesno</source_model>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <show_in_store>0</show_in_store>
183
+ </residence_delivery>
184
+ <allowed_ups_methods translate="label">
185
+ <label>Allowed UPS Methods</label>
186
+ <frontend_type>multiselect</frontend_type>
187
+ <source_model>carrier/source_upsmethod</source_model>
188
+ <sort_order>150</sort_order>
189
+ <show_in_default>1</show_in_default>
190
+ <show_in_website>1</show_in_website>
191
+ <show_in_store>0</show_in_store>
192
+ <can_be_empty>1</can_be_empty>
193
+ </allowed_ups_methods>
194
+ <allowed_fedex_methods translate="label">
195
+ <label>Allowed FEDEX Methods</label>
196
+ <frontend_type>multiselect</frontend_type>
197
+ <source_model>carrier/source_fedexmethod</source_model>
198
+ <sort_order>160</sort_order>
199
+ <show_in_default>1</show_in_default>
200
+ <show_in_website>1</show_in_website>
201
+ <show_in_store>0</show_in_store>
202
+ <can_be_empty>1</can_be_empty>
203
+ </allowed_fedex_methods>
204
+ <saturday_pickup translate="label">
205
+ <label>Is Saturday PickUp</label>
206
+ <frontend_type>select</frontend_type>
207
+ <source_model>adminhtml/system_config_source_yesno</source_model>
208
+ <sort_order>170</sort_order>
209
+ <show_in_default>1</show_in_default>
210
+ <show_in_website>1</show_in_website>
211
+ <show_in_store>0</show_in_store>
212
+ </saturday_pickup>
213
+ <saturday_delivery translate="label">
214
+ <label>Is Saturday Delivery</label>
215
+ <frontend_type>select</frontend_type>
216
+ <source_model>adminhtml/system_config_source_yesno</source_model>
217
+ <sort_order>180</sort_order>
218
+ <show_in_default>1</show_in_default>
219
+ <show_in_website>1</show_in_website>
220
+ <show_in_store>0</show_in_store>
221
+ </saturday_delivery>
222
+ <delivery_confirmation translate="label">
223
+ <label>Is Delivery Confirmation</label>
224
+ <frontend_type>select</frontend_type>
225
+ <source_model>adminhtml/system_config_source_yesno</source_model>
226
+ <sort_order>190</sort_order>
227
+ <show_in_default>1</show_in_default>
228
+ <show_in_website>1</show_in_website>
229
+ <show_in_store>0</show_in_store>
230
+ </delivery_confirmation>
231
+ <regular_pickup translate="label">
232
+ <label>Is Regular PickUp</label>
233
+ <frontend_type>select</frontend_type>
234
+ <source_model>adminhtml/system_config_source_yesno</source_model>
235
+ <sort_order>200</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>0</show_in_store>
239
+ </regular_pickup>
240
+ <thermal_label translate="label">
241
+ <label>Thermal Label</label>
242
+ <frontend_type>select</frontend_type>
243
+ <source_model>adminhtml/system_config_source_yesno</source_model>
244
+ <sort_order>210</sort_order>
245
+ <show_in_default>1</show_in_default>
246
+ <show_in_website>1</show_in_website>
247
+ <show_in_store>0</show_in_store>
248
+ </thermal_label>
249
+ <drop_off translate="label">
250
+ <label>Is Drop off</label>
251
+ <frontend_type>select</frontend_type>
252
+ <source_model>adminhtml/system_config_source_yesno</source_model>
253
+ <sort_order>220</sort_order>
254
+ <show_in_default>1</show_in_default>
255
+ <show_in_website>1</show_in_website>
256
+ <show_in_store>0</show_in_store>
257
+ </drop_off>
258
+ <free_method translate="label">
259
+ <label>Free Method</label>
260
+ <frontend_type>select</frontend_type>
261
+ <frontend_class>free-method</frontend_class>
262
+ <source_model>carrier/source_freemethod</source_model>
263
+ <sort_order>230</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <show_in_store>0</show_in_store>
267
+ </free_method>
268
+ <free_shipping_enable translate="label">
269
+ <label>Free Shipping with Minimum Order Amount</label>
270
+ <frontend_type>select</frontend_type>
271
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
272
+ <sort_order>240</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <show_in_store>0</show_in_store>
276
+ </free_shipping_enable>
277
+ <free_shipping_subtotal translate="label">
278
+ <label>Minimum Order Amount for Free Shipping</label>
279
+ <frontend_type>text</frontend_type>
280
+ <validate>validate-number validate-zero-or-greater</validate>
281
+ <sort_order>250</sort_order>
282
+ <show_in_default>1</show_in_default>
283
+ <show_in_website>1</show_in_website>
284
+ <show_in_store>0</show_in_store>
285
+ </free_shipping_subtotal>
286
+ <specificerrmsg translate="label">
287
+ <label>Displayed Error Message</label>
288
+ <frontend_type>textarea</frontend_type>
289
+ <sort_order>260</sort_order>
290
+ <show_in_default>1</show_in_default>
291
+ <show_in_website>1</show_in_website>
292
+ <show_in_store>1</show_in_store>
293
+ </specificerrmsg>
294
+ <sallowspecific translate="label">
295
+ <label>Ship to Applicable Countries</label>
296
+ <frontend_type>select</frontend_type>
297
+ <sort_order>270</sort_order>
298
+ <frontend_class>shipping-applicable-country</frontend_class>
299
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>1</show_in_website>
302
+ <show_in_store>0</show_in_store>
303
+ </sallowspecific>
304
+ <specificcountry translate="label">
305
+ <label>Ship to Specific Countries</label>
306
+ <frontend_type>multiselect</frontend_type>
307
+ <sort_order>280</sort_order>
308
+ <source_model>adminhtml/system_config_source_country</source_model>
309
+ <show_in_default>1</show_in_default>
310
+ <show_in_website>1</show_in_website>
311
+ <show_in_store>0</show_in_store>
312
+ <can_be_empty>1</can_be_empty>
313
+ </specificcountry>
314
+ <debug translate="label">
315
+ <label>Debug</label>
316
+ <frontend_type>select</frontend_type>
317
+ <source_model>adminhtml/system_config_source_yesno</source_model>
318
+ <sort_order>290</sort_order>
319
+ <show_in_default>1</show_in_default>
320
+ <show_in_website>1</show_in_website>
321
+ <show_in_store>0</show_in_store>
322
+ </debug>
323
+ <showmethod translate="label">
324
+ <label>Show Method if Not Applicable</label>
325
+ <frontend_type>select</frontend_type>
326
+ <sort_order>300</sort_order>
327
+ <frontend_class>shipping-skip-hide</frontend_class>
328
+ <source_model>adminhtml/system_config_source_yesno</source_model>
329
+ <show_in_default>1</show_in_default>
330
+ <show_in_website>1</show_in_website>
331
+ <show_in_store>0</show_in_store>
332
+ </showmethod>
333
+ <sort_order translate="label">
334
+ <label>Sort Order</label>
335
+ <frontend_type>text</frontend_type>
336
+ <sort_order>340</sort_order>
337
+ <show_in_default>1</show_in_default>
338
+ <show_in_website>1</show_in_website>
339
+ <show_in_store>0</show_in_store>
340
+ </sort_order>
341
+ </fields>
342
+ </parcelpro>
343
+ </groups>
344
+ </carriers>
345
+ </sections>
346
+ </config>
app/code/community/ParcelPro/Carrier/sql/carrier_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $installer->run("
5
+ DROP TABLE IF EXISTS {$this->getTable('parcelpro_carrier_config')};
6
+ CREATE TABLE {$this->getTable('parcelpro_carrier_config')} (
7
+ `index_id` int(11) unsigned NOT NULL auto_increment,
8
+ `carrier` varchar(255) NOT NULL default '',
9
+ `config_type` varchar(255) NOT NULL default '',
10
+ `config_key` varchar(255) NOT NULL default '',
11
+ `config_value` varchar(255) NOT NULL default '',
12
+ `apply_to` varchar(255) NOT NULL default '',
13
+ PRIMARY KEY (`index_id`)
14
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
15
+
16
+ INSERT INTO `{$this->getTable('parcelpro_carrier_config')}` (`index_id`, `carrier`, `config_type`, `config_key`, `config_value`, `apply_to`) VALUES
17
+ (1, '', 'carrier', 'UPS', 'UPS', '1'),
18
+ (2, '', 'carrier', 'FEDEX', 'FEDEX', '2'),
19
+ (3, 'UPS', 'method', '01', 'Next Day Air', ''),
20
+ (4, 'UPS', 'method', '02', '2nd Day Air', ''),
21
+ (5, 'FEDEX', 'method', '01-INT', 'International Priority', ''),
22
+ (6, 'FEDEX', 'method', '01-DOM', 'Priority Overnight', ''),
23
+ (7, 'FEDEX', 'method', '03-DOM', '2 Day', ''),
24
+ (8, 'FEDEX', 'method', '05', 'Standard Overnight', ''),
25
+ (9, 'UPS', 'packaging', '25', '10KG BOX', '01'),
26
+ (10, 'UPS', 'packaging', '24', '25KG BOX', '01'),
27
+ (11, 'UPS', 'packaging', '21', 'EXPRESS BOX', '01'),
28
+ (12, 'UPS', 'packaging', '01', 'LETTER', '01'),
29
+ (13, 'UPS', 'packaging', '04', 'PAK', '01'),
30
+ (14, 'UPS', 'packaging', '03', 'TUBE', '01'),
31
+ (15, 'UPS', 'packaging', '02', 'Your Packaging...', '01'),
32
+ (16, 'UPS', 'packaging', '25', '10KG BOX', '02'),
33
+ (17, 'UPS', 'packaging', '24', '25KG BOX', '02'),
34
+ (18, 'UPS', 'packaging', '21', 'EXPRESS BOX', '02'),
35
+ (19, 'UPS', 'packaging', '01', 'LETTER', '02'),
36
+ (20, 'UPS', 'packaging', '04', 'PAK', '02'),
37
+ (21, 'UPS', 'packaging', '03', 'TUBE', '02'),
38
+ (22, 'UPS', 'packaging', '02', 'Your Packaging...', '02'),
39
+ (23, 'FEDEX', 'packaging', 'LARGE BOX', 'LARGE FEDEX BOX', '01-INT'),
40
+ (24, 'FEDEX', 'packaging', 'MEDIUM BOX', 'MEDIUM FEDEX BOX', '01-INT'),
41
+ (25, 'FEDEX', 'packaging', 'SMALL BOX', 'SMALL FEDEX BOX', '01-INT'),
42
+ (26, 'FEDEX', 'packaging', '02', 'Your Packaging...', '01-INT'),
43
+ (27, 'FEDEX', 'packaging', 'LARGE BOX', 'LARGE FEDEX BOX', '01-DOM'),
44
+ (28, 'FEDEX', 'packaging', 'MEDIUM BOX', 'MEDIUM FEDEX BOX', '01-DOM'),
45
+ (29, 'FEDEX', 'packaging', 'SMALL BOX', 'SMALL FEDEX BOX', '01-DOM'),
46
+ (30, 'FEDEX', 'packaging', '02', 'Your Packaging...', '01-DOM'),
47
+ (31, 'FEDEX', 'packaging', 'LARGE BOX', 'LARGE FEDEX BOX', '03-DOM'),
48
+ (32, 'FEDEX', 'packaging', 'MEDIUM BOX', 'MEDIUM FEDEX BOX', '03-DOM'),
49
+ (33, 'FEDEX', 'packaging', 'SMALL BOX', 'SMALL FEDEX BOX', '03-DOM'),
50
+ (34, 'FEDEX', 'packaging', '02', 'Your Packaging...', '03-DOM'),
51
+ (35, 'FEDEX', 'packaging', 'LARGE BOX', 'LARGE FEDEX BOX', '05'),
52
+ (36, 'FEDEX', 'packaging', 'MEDIUM BOX', 'MEDIUM FEDEX BOX', '05'),
53
+ (37, 'FEDEX', 'packaging', 'SMALL BOX', 'SMALL FEDEX BOX', '05'),
54
+ (38, 'FEDEX', 'packaging', '02', 'Your Packaging...', '05'),
55
+ (39, 'UPS', 'special_services', 'NO_SIGNATURE_REQUIRED', 'Not Required', 'UPS'),
56
+ (40, 'UPS', 'special_services', 'ADULT', 'Adult Signature', 'UPS'),
57
+ (41, 'UPS', 'special_services', 'DIRECT', 'Direct Signature', 'UPS'),
58
+ (42, 'UPS', 'special_services', 'COD', 'COD', 'UPS'),
59
+ (43, 'UPS', 'special_services', 'saturday_pickup', 'Saturday pickup', 'UPS'),
60
+ (44, 'UPS', 'special_services', 'saturday_delivery', 'Saturday delivery', 'UPS'),
61
+ (45, 'UPS', 'special_services', 'hold_at_fedex_location', 'Hold At Fedex Location', 'UPS'),
62
+ (46, 'UPS', 'special_services', 'thermal_label', 'Thermal label', 'UPS'),
63
+ (47, 'FEDEX', 'special_services', 'NO_SIGNATURE_REQUIRED', 'Not Required', 'FEDEX'),
64
+ (48, 'FEDEX', 'special_services', 'ADULT', 'Adult Signature', 'FEDEX'),
65
+ (49, 'FEDEX', 'special_services', 'DIRECT', 'Direct Signature', 'FEDEX'),
66
+ (50, 'FEDEX', 'special_services', 'COD', 'COD', 'FEDEX'),
67
+ (51, 'FEDEX', 'special_services', 'saturday_pickup', 'Saturday pickup', 'FEDEX'),
68
+ (52, 'FEDEX', 'special_services', 'saturday_delivery', 'Saturday delivery', 'FEDEX'),
69
+ (53, 'FEDEX', 'special_services', 'hold_at_fedex_location', 'Hold At Fedex Location', 'FEDEX'),
70
+ (54, 'FEDEX', 'special_services', 'thermal_label', 'Thermal label', 'FEDEX');
71
+
72
+ ");
73
+
74
+ $installer->addAttribute('catalog_product', 'insured', array(
75
+ 'group' => 'General',
76
+ 'type' => Varien_Db_Ddl_Table::TYPE_VARCHAR,
77
+ 'backend' => '',
78
+ 'frontend' => '',
79
+ 'label' => 'Insured',
80
+ 'input' => 'text',
81
+ 'class' => '',
82
+ 'source' => '',
83
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
84
+ 'visible' => true,
85
+ 'required' => false,
86
+ 'user_defined' => true,
87
+ 'default' => '',
88
+ 'searchable' => true,
89
+ 'filterable' => true,
90
+ 'comparable' => true,
91
+ 'visible_on_front' => true,
92
+ 'used_in_product_listing' => true,
93
+ 'unique' => false,
94
+ 'apply_to' => 'simple,configurable,virtual',
95
+ 'is_configurable' => false
96
+ ));
97
+
98
+ $installer->endSetup();
app/etc/modules/ParcelPro_Carrier.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ParcelPro_Carrier>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Shipping />
9
+ </depends>
10
+ </ParcelPro_Carrier>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ParcelPro_Carrier</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://www.mozilla.org/MPL/2.0/">MPL 2.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Parcel Pro for Magento is a web-based Insured Shipping solution that integrates with your Magento online store, adding Parcel Pro as one of your shipping options. It allows you to set the price of shipping and insurance coverage quickly and easily.</summary>
10
+ <description>Parcel Pro for Magento is a web-based Insured Shipping solution that integrates with your Magento online store. It adds Parcel Pro as one of your shipping options, allowing you to set the price of shipping and insurance coverage easily. You must have a Magento store. By having Parcel Pro for Magento installed into your Magento store, you&#x2019;ll have a powerful new option for your customers to choose from when selecting Insured Shipping. With solid integration with your favorite carriers, Parcel Pro for Magento lets your customers check out in a breeze, with the costs of shipping and insurance embedded into your price.</description>
11
+ <notes>Version 1.0.1&#xD;
12
+ Actually use default location for ShipFrom&#xD;
13
+ Some error logging added&#xD;
14
+ &#xD;
15
+ Version 1.0.0&#xD;
16
+ New release.</notes>
17
+ <authors><author><name>Parcel Pro, Inc.</name><user>ParcelProInc</user><email>techsupport@parcelpro.com</email></author></authors>
18
+ <date>2014-09-23</date>
19
+ <time>21:19:30</time>
20
+ <contents><target name="magecommunity"><dir name="ParcelPro"><dir name="Carrier"><dir name="Block"><dir name="Adminhtml"><dir name="Button"><dir name="Refresh"><file name="Cms.php" hash="4e17c2e2488321dec06785af3b3c3706"/></dir></dir></dir></dir><dir name="Helper"><file name="Parcelpro.php" hash="274e40cd23bb5ef6fcaaa2b01004c2dd"/></dir><dir name="Model"><file name="Carrier.php" hash="8d76613b4d87785722534a63ba22e1a3"/><file name="Config.php" hash="1a524a99e831bcbad22ffd50316aec44"/><dir name="Mysql4"><dir name="Config"><file name="Collection.php" hash="60720e05a974b362891d4dba01694132"/></dir><file name="Config.php" hash="ac407fcd7973e28342bc99a24fad7b4a"/></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="4c6b2c661d616ccce831185d30cc340e"/></dir></dir><dir name="Source"><file name="Carriers.php" hash="fbae840c7a2bb07d36f61aab7cf4d960"/><file name="Dropoff.php" hash="ab1c1c54e22ed3f1c628cd2f34b50ea8"/><file name="Fedexmethod.php" hash="1966f6b0e4cb1f5a8cbb8be5a2b38981"/><file name="Freemethod.php" hash="2f590b14abae6718abdd8ab1ebbca2b8"/><file name="Packaging.php" hash="85e5e9416c4ba68bedd12558edafe384"/><file name="Unitofmeasure.php" hash="4048107787504d7aef1b662de777e93d"/><file name="Upsmethod.php" hash="4eed70c1e0f051622251377dd2ffe050"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="RefreshController.php" hash="01dc45dd06e8af8968cce7fbaa554cb9"/></dir><file name="IndexController.php" hash="dd116c50612320505894e151b43a8fcc"/></dir><dir name="etc"><file name="config.xml" hash="81cec73e236e689be83576e56cb8ae98"/><file name="system.xml" hash="25e4b2b1e7c61b4bf55d5015d5cab0df"/></dir><dir name="sql"><dir name="carrier_setup"><file name="mysql4-install-1.0.0.php" hash="42faff48ed0752ba42739316ac02e890"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ParcelPro_Carrier.xml" hash=""/></dir></target></contents>
21
+ <compatible/>
22
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
23
+ </package>