Shopgo_ShippingCore - Version 1.3.7

Version Notes

The first release of ShopGo Shipping Core module.

Download this release

Release Info

Developer Moe Ghashim
Extension Shopgo_ShippingCore
Version 1.3.7
Comparing to
See all releases


Code changes from version 1.3.6 to 1.3.7

Files changed (26) hide show
  1. app/code/community/Shopgo/ShippingCore/Block/Adminhtml/System/Config/Form/DwaButton.php +86 -0
  2. app/code/community/Shopgo/ShippingCore/Helper/Abstract.php +398 -0
  3. app/code/community/Shopgo/ShippingCore/Helper/Data.php +29 -0
  4. app/code/community/Shopgo/ShippingCore/Model/Carrier/Abstract.php +65 -0
  5. app/code/community/Shopgo/ShippingCore/Model/Carrier/Aramex.php +101 -0
  6. app/code/community/Shopgo/ShippingCore/Model/Carrier/Skynet.php +95 -0
  7. app/code/community/Shopgo/ShippingCore/Model/Core.php +101 -0
  8. app/code/community/Shopgo/ShippingCore/Model/Dwa.php +146 -0
  9. app/code/community/Shopgo/ShippingCore/Model/Magento/Shipping/Info.php +109 -0
  10. app/code/community/Shopgo/ShippingCore/Model/Observer.php +112 -0
  11. app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Activepaymentmethod.php +60 -0
  12. app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Allowedcurrencies.php +67 -0
  13. app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Attributeset.php +57 -0
  14. app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Attributesetgroup.php +72 -0
  15. app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Codcurrency.php +79 -0
  16. app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Height.php +54 -0
  17. app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Length.php +54 -0
  18. app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Width.php +54 -0
  19. app/code/community/Shopgo/ShippingCore/controllers/Adminhtml/Sales/Order/ShipmentController.php +126 -0
  20. app/code/community/Shopgo/ShippingCore/controllers/Adminhtml/Shopgo/ShippingcoreController.php +99 -0
  21. app/code/community/Shopgo/ShippingCore/etc/adminhtml.xml +85 -0
  22. app/code/community/Shopgo/ShippingCore/etc/config.xml +105 -0
  23. app/code/community/Shopgo/ShippingCore/etc/system.xml +256 -0
  24. app/code/community/Shopgo/ShippingCore/sql/shippingcore_setup/mysql4-install-1.1.2.php +65 -0
  25. app/design/frontend/base/default/template/shopgo/shipping_core/checkout/cart/shipping.phtml +131 -0
  26. package.xml +7 -6
app/code/community/Shopgo/ShippingCore/Block/Adminhtml/System/Config/Form/DwaButton.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Dimensional weight attributes button block
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Block_Adminhtml_System_Config_Form_DwaButton extends Mage_Adminhtml_Block_System_Config_Form_Field
27
+ {
28
+ /**
29
+ * Set phtml template
30
+ *
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ $template = $this->setTemplate('shopgo/shipping_core/system/config/dwa_button.phtml');
36
+ }
37
+
38
+ /**
39
+ * Get the button and scripts contents
40
+ *
41
+ * @param Varien_Data_Form_Element_Abstract $element
42
+ * @return string
43
+ */
44
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
45
+ {
46
+ return $this->_toHtml();
47
+ }
48
+
49
+ /**
50
+ * Get set attributes ajax action URL
51
+ *
52
+ * @return string
53
+ */
54
+ public function getSetAttributesAjaxActionUrl()
55
+ {
56
+ return Mage::helper('adminhtml')->getUrl('adminhtml/shopgo_shippingcore/setdwattributes');
57
+ }
58
+
59
+ /**
60
+ * Get attribute set groups ajax action URL
61
+ *
62
+ * @return string
63
+ */
64
+ public function getAsgAjaxActionUrl()
65
+ {
66
+ return Mage::helper('adminhtml')->getUrl('adminhtml/shopgo_shippingcore/getdwasetgroups');
67
+ }
68
+
69
+ /**
70
+ * Get the button and scripts contents
71
+ *
72
+ * @return string
73
+ */
74
+ public function getButtonHtml()
75
+ {
76
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(
77
+ array(
78
+ 'id' => 'shipping_core_dwa_trigger',
79
+ 'label' => $this->helper('adminhtml')->__('Set Attributes'),
80
+ 'onclick' => 'javascript:shopgo.shippingCore.dwaButton.setAttributes(); return false;'
81
+ )
82
+ );
83
+
84
+ return $button->toHtml();
85
+ }
86
+ }
app/code/community/Shopgo/ShippingCore/Helper/Abstract.php ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Abstract helper class
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ abstract class Shopgo_ShippingCore_Helper_Abstract extends Shopgo_Core_Helper_Abstract
27
+ {
28
+ /**
29
+ * Dimensional weight attribute length
30
+ */
31
+ const LENGTH = 'length';
32
+
33
+ /**
34
+ * Dimensional weight attribute width
35
+ */
36
+ const WIDTH = 'width';
37
+
38
+ /**
39
+ * Dimensional weight attribute height
40
+ */
41
+ const HEIGHT = 'height';
42
+
43
+
44
+ /**
45
+ * Log file name
46
+ *
47
+ * @var string
48
+ */
49
+ protected $_logFile = 'shopgo_shipping_core.log';
50
+
51
+ /**
52
+ * Cash on delivery enabled shipping methods
53
+ *
54
+ * @var array
55
+ */
56
+ protected $_codEnabledShippingMethods = array();
57
+
58
+
59
+ /**
60
+ * Improved currency convert method
61
+ *
62
+ * @param float $price
63
+ * @param string $from
64
+ * @param string $to
65
+ * @param string $output
66
+ * @param int $round
67
+ * @return array
68
+ */
69
+ public function currencyConvert($price, $from, $to, $output = '', $round = null)
70
+ {
71
+ $from = strtoupper($from);
72
+ $to = strtoupper($to);
73
+
74
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
75
+ $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
76
+
77
+ switch ($from) {
78
+ case '_BASE_':
79
+ $from = $baseCurrencyCode;
80
+ break;
81
+ case '_CURRENT_':
82
+ $from = $currentCurrencyCode;
83
+ break;
84
+ }
85
+
86
+ switch ($to) {
87
+ case '_BASE_':
88
+ $to = $baseCurrencyCode;
89
+ break;
90
+ case '_CURRENT_':
91
+ $to = $currentCurrencyCode;
92
+ break;
93
+ }
94
+
95
+ $output = strtolower($output);
96
+
97
+ $error = false;
98
+ $result = array('price' => $price, 'currency' => $from);
99
+
100
+ if ($from != $to) {
101
+ $allowedCurrencies = Mage::getModel('directory/currency')
102
+ ->getConfigAllowCurrencies();
103
+
104
+ $rates = Mage::getModel('directory/currency')
105
+ ->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
106
+
107
+ if (empty($rates) || empty($rates[$from]) || empty($rates[$to])) {
108
+ $error = true;
109
+ }
110
+
111
+ if ($error) {
112
+ $this->log(
113
+ sprintf('Currency conversion error: From "%s %s" To "%s"',
114
+ $price, $from, $to)
115
+ );
116
+
117
+ if (isset($result[$output])) {
118
+ return $result[$output];
119
+ } else {
120
+ return $result;
121
+ }
122
+ }
123
+
124
+ $result = array(
125
+ 'price' => ($price * $rates[$to]) / $rates[$from],
126
+ 'currency' => $to
127
+ );
128
+ }
129
+
130
+ if (is_int($round)) {
131
+ $result['price'] = round($result['price'], $round);
132
+ }
133
+
134
+ if (isset($result[$output])) {
135
+ return $result[$output];
136
+ }
137
+
138
+ return $result;
139
+ }
140
+
141
+ /**
142
+ * Convert shipping rate to base currency
143
+ *
144
+ * @param float $price
145
+ * @param string $priceCurrencyCode
146
+ * @return array
147
+ */
148
+ public function convertRateCurrency($price, $priceCurrencyCode)
149
+ {
150
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
151
+ $result = array('price' => $price, 'currency' => $priceCurrencyCode);
152
+
153
+ if ($priceCurrencyCode != $baseCurrencyCode) {
154
+ $result = $this->currencyConvert(
155
+ $price, $priceCurrencyCode, $baseCurrencyCode
156
+ );
157
+ }
158
+
159
+ return $result;
160
+ }
161
+
162
+ /**
163
+ * Check if order's shipping method is a Shopgo shipping method
164
+ *
165
+ * @param string $carrierCode
166
+ * @return boolean
167
+ */
168
+ public function isShopgoShippingMethod($carrierCode)
169
+ {
170
+ $result = false;
171
+
172
+ switch (true) {
173
+ case Mage::getModel('shippingcore/carrier_aramex')->isUsed($carrierCode):
174
+ $result = $carrierCode;
175
+ break;
176
+ case Mage::getModel('shippingcore/carrier_skynet')->isUsed($carrierCode):
177
+ $result = $carrierCode;
178
+ break;
179
+ }
180
+
181
+ return $result;
182
+ }
183
+
184
+ /**
185
+ * Get order's shipping method adminhtml ship page forms
186
+ *
187
+ * @param string $carrierCode
188
+ * @param Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Form $block
189
+ * @return string
190
+ */
191
+ public function getAdminhtmlShipmentForms($carrierCode, $block)
192
+ {
193
+ $html = "";
194
+
195
+ switch ($carrierCode) {
196
+ case 'aramex':
197
+ $html = Mage::helper('aramexshipping')
198
+ ->_getAdminhtmlShipmentForms($block);
199
+ break;
200
+ case 'skynet':
201
+ $html = Mage::helper('skynetshipping')
202
+ ->_getAdminhtmlShipmentForms($block);
203
+ break;
204
+ }
205
+
206
+ return $html;
207
+ }
208
+
209
+ /**
210
+ * Get dimensional weight attributes names
211
+ *
212
+ * @return array
213
+ */
214
+ public function getDwaNames()
215
+ {
216
+ $attributes = array(
217
+ self::LENGTH,
218
+ self::WIDTH,
219
+ self::HEIGHT
220
+ );
221
+
222
+ return $attributes;
223
+ }
224
+
225
+ /**
226
+ * Get dimensional weight attributes codes
227
+ *
228
+ * @return array
229
+ */
230
+ public function getDwaCodes()
231
+ {
232
+ $dwaSettings = $this->getShippingSettings('dwa');
233
+ $attributes = $this->getDwaNames();
234
+ $result = array();
235
+
236
+ foreach ($attributes as $attr) {
237
+ $result[$attr] = $dwaSettings[$attr];
238
+ }
239
+
240
+ return $result;
241
+ }
242
+
243
+ /**
244
+ * Get cash on delivery methods list
245
+ *
246
+ * @param array $toArray
247
+ * @return array|string
248
+ */
249
+ public function getCodMethodList($toArray = true)
250
+ {
251
+ $codSettings = $this->getShippingSettings('cod');
252
+ $methods = $codSettings['payment_methods'];
253
+
254
+ return $toArray ? explode(',', $methods) : $methods;
255
+ }
256
+
257
+ /**
258
+ * Get/Set/Unset cash on delivery filtering enabled shipping methods session values
259
+ *
260
+ * @param string $action
261
+ * @param mixed $value
262
+ * @return mixed
263
+ */
264
+ public function codFilteringEnabledShippingMethods($action = 'get', $value = null)
265
+ {
266
+ $result = null;
267
+ $session = Mage::getSingleton('checkout/session');
268
+
269
+ switch ($action) {
270
+ case 'get':
271
+ $result = $session->getCodFilteringEnabledShippingMethods();
272
+ break;
273
+ case 'set':
274
+ $result = $session->setCodFilteringEnabledShippingMethods($value);
275
+ break;
276
+ case 'uns':
277
+ $result = $session->unsCodFilteringEnabledShippingMethods();
278
+ break;
279
+ }
280
+
281
+ return $result;
282
+ }
283
+
284
+ /**
285
+ * Convert street address to a single line
286
+ *
287
+ * @param string $address
288
+ * @return string
289
+ */
290
+ public function getSingleLineStreetAddress($address)
291
+ {
292
+ return is_string($address)
293
+ ? trim(preg_replace('/\s+/', ' ', $address)) // Replace newlines with spaces
294
+ : $address;
295
+ }
296
+
297
+ /**
298
+ * Get cash on delivery currency
299
+ *
300
+ * @param Mage_Sales_Model_Order|null $order
301
+ * @return string
302
+ */
303
+ public function getCodCurrency($order = null)
304
+ {
305
+ $currency = Mage::app()->getStore()->getBaseCurrencyCode();
306
+ $codSettings = $this->getShippingSettings('cod');
307
+
308
+ switch ($codSettings['currency']) {
309
+ case Shopgo_ShippingCore_Model_System_Config_Source_Codcurrency::ORDER:
310
+ if (is_object($order) && $order instanceof Mage_Sales_Model_Order) {
311
+ $currency = $order->getOrderCurrencyCode();
312
+ }
313
+ break;
314
+ case Shopgo_ShippingCore_Model_System_Config_Source_Codcurrency::CURRENT:
315
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
316
+ break;
317
+ case Shopgo_ShippingCore_Model_System_Config_Source_Codcurrency::SPECIFIC:
318
+ if ($codSettings['specific_currency']) {
319
+ $allowedCurrencies =
320
+ Mage::getModel('shippingcore/system_config_source_allowedcurrencies')
321
+ ->toOptionArray();
322
+
323
+ foreach ($allowedCurrencies as $ac) {
324
+ if ($codSettings['specific_currency'] == $ac['value']) {
325
+ $currency = $codSettings['specific_currency'];
326
+ break;
327
+ }
328
+ }
329
+ }
330
+ break;
331
+ }
332
+
333
+ return $currency;
334
+ }
335
+
336
+ /**
337
+ * Get system configuration sales shipping settings
338
+ *
339
+ * @param string|array $group
340
+ * @return array
341
+ */
342
+ public function getShippingSettings($group = '')
343
+ {
344
+ $settings = array(
345
+ 'origin' => array('street_line3'),
346
+ 'additional_info' => array(
347
+ 'person_title', 'person_name',
348
+ 'company', 'store_description',
349
+ 'phone_number', 'phone_number_ext',
350
+ 'phone_number2', 'phone_number2_ext',
351
+ 'faxnumber', 'email',
352
+ 'cellphone'
353
+ ),
354
+ 'dwa' => array(
355
+ 'length', 'width', 'height'
356
+ ),
357
+ 'cod' => array(
358
+ 'payment_methods', 'currency', 'specific_currency'
359
+ )
360
+ );
361
+
362
+ switch (true) {
363
+ case is_string($group) && isset($settings[$group]):
364
+ $settings = $settings[$group];
365
+
366
+ foreach ($settings as $field) {
367
+ $settings[$field] = Mage::getStoreConfig(
368
+ 'shipping/' . $group . '/' . $field
369
+ );
370
+ }
371
+
372
+ break;
373
+ case is_array($group) && !empty($group):
374
+ foreach ($settings as $_group => $fields) {
375
+ if (!in_array($_group, $group)) {
376
+ continue;
377
+ }
378
+ foreach ($fields as $field) {
379
+ $settings[$_group][$field] = Mage::getStoreConfig(
380
+ 'shipping/' . $_group . '/' . $field
381
+ );
382
+ }
383
+ }
384
+
385
+ break;
386
+ default:
387
+ foreach ($settings as $_group => $fields) {
388
+ foreach ($fields as $field) {
389
+ $settings[$_group][$field] = Mage::getStoreConfig(
390
+ 'shipping/' . $_group . '/' . $field
391
+ );
392
+ }
393
+ }
394
+ }
395
+
396
+ return $settings;
397
+ }
398
+ }
app/code/community/Shopgo/ShippingCore/Helper/Data.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Data helper
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Helper_Data extends Shopgo_ShippingCore_Helper_Abstract
27
+ {
28
+
29
+ }
app/code/community/Shopgo/ShippingCore/Model/Carrier/Abstract.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Abstract carrier model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ abstract class Shopgo_ShippingCore_Model_Carrier_Abstract extends Mage_Core_Model_Abstract
27
+ {
28
+ /**
29
+ * Process shipment tracking info
30
+ *
31
+ * @param array $trackingInfo
32
+ * @return array
33
+ */
34
+ public function processTrackingInfo($trackingInfo)
35
+ {
36
+ if (count($trackingInfo) == 1) {
37
+ $trackingInfo = $trackingInfo[0];
38
+ } else {
39
+ foreach ($trackingInfo as $i => $ti) {
40
+ $gti = array();
41
+
42
+ if (isset($trackingInfo[$i + 1])) {
43
+ $gti = array_merge($ti, $trackingInfo[$i + 1]);
44
+ }
45
+
46
+ if (!empty($gti)) {
47
+ $trackingInfo = array_merge($trackingInfo, $gti);
48
+ }
49
+ }
50
+ }
51
+
52
+ return $trackingInfo;
53
+ }
54
+
55
+ /**
56
+ * Process shipment tracking info by track ID
57
+ *
58
+ * @param array $trackingInfo
59
+ * @return array
60
+ */
61
+ public function processTrackingInfoByTrackId($trackingInfo)
62
+ {
63
+ return array($trackingInfo);
64
+ }
65
+ }
app/code/community/Shopgo/ShippingCore/Model/Carrier/Aramex.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Aramex carrier model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_Carrier_Aramex extends Shopgo_ShippingCore_Model_Carrier_Abstract
27
+ {
28
+ /**
29
+ * Aramex shipping module name
30
+ */
31
+ const MODULE_NAME = 'Shopgo_AramexShipping';
32
+
33
+
34
+ /**
35
+ * Check if module is active and shipping service is enabled
36
+ *
37
+ * @return bool
38
+ */
39
+ public function isEnabled()
40
+ {
41
+ $result = false;
42
+
43
+ if (Mage::helper('core')->isModuleEnabled(self::MODULE_NAME)) {
44
+ $result = Mage::getModel('aramexshipping/shipment')->isEnabled();
45
+ }
46
+
47
+ return $result;
48
+ }
49
+
50
+ /**
51
+ * Check if shipping method is enabled and used in an order
52
+ *
53
+ * @param string $carrierCode
54
+ * @return bool
55
+ */
56
+ public function isUsed($carrierCode)
57
+ {
58
+ $result = false;
59
+
60
+ if ($this->isEnabled()) {
61
+ $result = $carrierCode == Mage::getModel('aramexshipping/carrier_aramex')
62
+ ->getCarrierCode();
63
+ }
64
+
65
+ return $result;
66
+ }
67
+
68
+ /**
69
+ * Save shipment
70
+ *
71
+ * @param Mage_Sales_Model_Order_Shipment $shipment
72
+ * @param array $data
73
+ * @return bool
74
+ */
75
+ public function saveShipment($shipment, $data)
76
+ {
77
+ $result = true;
78
+
79
+ if (isset($data['aramex'])) {
80
+ $result = Mage::getModel('aramexshipping/shipment')->prepareShipment(
81
+ $shipment,
82
+ $data['aramex']
83
+ );
84
+ }
85
+
86
+ if (!$result) {
87
+ if (isset($data['aramex']['shipment'])) {
88
+ Mage::getSingleton('adminhtml/session')
89
+ ->setShipAramexShipmentData($data['aramex']['shipment']);
90
+ }
91
+
92
+ if (isset($data['aramex']['pickup']['enabled'])
93
+ && $data['aramex']['pickup']['enabled']) {
94
+ Mage::getSingleton('adminhtml/session')
95
+ ->setShipAramexPickupData($data['aramex']['pickup']);
96
+ }
97
+ }
98
+
99
+ return $result;
100
+ }
101
+ }
app/code/community/Shopgo/ShippingCore/Model/Carrier/Skynet.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Skynet carrier model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_Carrier_Skynet extends Shopgo_ShippingCore_Model_Carrier_Abstract
27
+ {
28
+ /**
29
+ * SkyNet shipping module name
30
+ */
31
+ const MODULE_NAME = 'Shopgo_SkynetShipping';
32
+
33
+
34
+ /**
35
+ * Check if module is active and shipping service is enabled
36
+ *
37
+ * @return bool
38
+ */
39
+ public function isEnabled()
40
+ {
41
+ $result = false;
42
+
43
+ if (Mage::helper('core')->isModuleEnabled(self::MODULE_NAME)) {
44
+ $result = Mage::getModel('skynetshipping/shipment')->isEnabled();
45
+ }
46
+
47
+ return $result;
48
+ }
49
+
50
+ /**
51
+ * Check if shipping method is enabled and used in an order
52
+ *
53
+ * @param string $carrierCode
54
+ * @return bool
55
+ */
56
+ public function isUsed($carrierCode)
57
+ {
58
+ $result = false;
59
+
60
+ if ($this->isEnabled()) {
61
+ $result = $carrierCode == Mage::getModel('skynetshipping/carrier_skynet')
62
+ ->getCarrierCode();
63
+ }
64
+
65
+ return $result;
66
+ }
67
+
68
+ /**
69
+ * Save shipment
70
+ *
71
+ * @param Mage_Sales_Model_Order_Shipment $shipment
72
+ * @param array $data
73
+ * @return bool
74
+ */
75
+ public function saveShipment($shipment, $data)
76
+ {
77
+ $result = true;
78
+
79
+ if (isset($data['skynet'])) {
80
+ $result = Mage::getModel('skynetshipping/shipment')->prepareShipment(
81
+ $shipment,
82
+ $data['skynet']
83
+ );
84
+ }
85
+
86
+ if (!$result) {
87
+ if (isset($data['skynet']['shipment'])) {
88
+ Mage::getSingleton('adminhtml/session')
89
+ ->setShipSkynetShipmentData($data['skynet']['shipment']);
90
+ }
91
+ }
92
+
93
+ return $result;
94
+ }
95
+ }
app/code/community/Shopgo/ShippingCore/Model/Core.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Core model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_Core extends Mage_Core_Model_Abstract
27
+ {
28
+ /**
29
+ * Save shipment
30
+ *
31
+ * @param Mage_Sales_Model_Order_Shipment $shipment
32
+ * @param array $data
33
+ * @return bool
34
+ */
35
+ public function saveShipment($shipment, $data)
36
+ {
37
+ $result = false;
38
+ $carrierCode = $shipment->getOrder()->getShippingCarrier()->getCarrierCode();
39
+
40
+ switch (true) {
41
+ case Mage::getModel('shippingcore/carrier_aramex')->isUsed($carrierCode):
42
+ $result = Mage::getModel('shippingcore/carrier_aramex')
43
+ ->saveShipment($shipment, $data);
44
+ break;
45
+ case Mage::getModel('shippingcore/carrier_skynet')->isUsed($carrierCode):
46
+ $result = Mage::getModel('shippingcore/carrier_skynet')
47
+ ->saveShipment($shipment, $data);
48
+ break;
49
+ }
50
+
51
+ return $result;
52
+ }
53
+
54
+ /**
55
+ * Process shipment tracking info
56
+ *
57
+ * @param array $trackingInfo
58
+ * @param string $carrierCode
59
+ * @return array
60
+ */
61
+ public function processTrackingInfo($trackingInfo, $carrierCode)
62
+ {
63
+ switch (true) {
64
+ case Mage::getModel('shippingcore/carrier_aramex')->isUsed($carrierCode):
65
+ $trackingInfo = Mage::getModel('shippingcore/carrier_aramex')
66
+ ->processTrackingInfo($trackingInfo);
67
+ break;
68
+ case Mage::getModel('shippingcore/carrier_skynet')->isUsed($carrierCode):
69
+ $trackingInfo = Mage::getModel('shippingcore/carrier_skynet')
70
+ ->processTrackingInfo($trackingInfo);
71
+ break;
72
+ }
73
+
74
+ return $trackingInfo;
75
+ }
76
+
77
+ /**
78
+ * Process shipment tracking info by track ID
79
+ *
80
+ * @param array $trackingInfo
81
+ * @param string $carrierCode
82
+ * @return array
83
+ */
84
+ public function processTrackingInfoByTrackId($trackingInfo, $carrierCode)
85
+ {
86
+ switch (true) {
87
+ case Mage::getModel('shippingcore/carrier_aramex')->isUsed($carrierCode):
88
+ $trackingInfo = Mage::getModel('shippingcore/carrier_aramex')
89
+ ->processTrackingInfoByTrackId($trackingInfo);
90
+ break;
91
+ case Mage::getModel('shippingcore/carrier_skynet')->isUsed($carrierCode):
92
+ $trackingInfo = Mage::getModel('shippingcore/carrier_skynet')
93
+ ->processTrackingInfoByTrackId($trackingInfo);
94
+ break;
95
+ default:
96
+ $trackingInfo = array(array($trackingInfo));
97
+ }
98
+
99
+ return $trackingInfo;
100
+ }
101
+ }
app/code/community/Shopgo/ShippingCore/Model/Dwa.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Dimensional weight attributes model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_Dwa extends Mage_Core_Model_Abstract
27
+ {
28
+ /**
29
+ * CONFIG path constant: LENGTH
30
+ */
31
+ const XML_PATH_DWA_LENGTH = 'shipping/dwa/length';
32
+
33
+ /**
34
+ * CONFIG path constant: WIDTH
35
+ */
36
+ const XML_PATH_DWA_WIDTH = 'shipping/dwa/width';
37
+
38
+ /**
39
+ * CONFIG path constant: HEIGHT
40
+ */
41
+ const XML_PATH_DWA_HEIGHT = 'shipping/dwa/height';
42
+
43
+
44
+ /**
45
+ * Set dimensional weight attributes
46
+ *
47
+ * @param string $attrSet
48
+ * @param string $attrSetGroup
49
+ * @param Mage_Catalog_Model_Resource_Setup $setup
50
+ * @return bool
51
+ */
52
+ public function setDwAttributes($attrSet, $attrSetGroup, $setup)
53
+ {
54
+ $result = true;
55
+
56
+ $attributes = array(
57
+ array(
58
+ 'code' => 'length',
59
+ 'label' => 'Length',
60
+ 'config_path' => self::XML_PATH_DWA_LENGTH
61
+ ),
62
+ array(
63
+ 'code' => 'width',
64
+ 'label' => 'Width',
65
+ 'config_path' => self::XML_PATH_DWA_WIDTH
66
+ ),
67
+ array(
68
+ 'code' => 'height',
69
+ 'label' => 'Height',
70
+ 'config_path' => self::XML_PATH_DWA_HEIGHT
71
+ )
72
+ );
73
+
74
+ foreach ($attributes as $attrData) {
75
+ $result = $result
76
+ & $this->_addAttribute($attrData, $attrSet, $attrSetGroup, $setup);
77
+ }
78
+
79
+ return $result;
80
+ }
81
+
82
+ /**
83
+ * Add attribute
84
+ *
85
+ * @param array $data
86
+ * @param string $attrSet
87
+ * @param string $attrSetGroup
88
+ * @param Mage_Catalog_Model_Resource_Setup|null $setup
89
+ * @return bool
90
+ */
91
+ private function _addAttribute($data, $attrSet = 'default', $attrSetGroup = 'General', $setup = null)
92
+ {
93
+ $result = true;
94
+
95
+ if (empty($setup)) {
96
+ $setup = Mage::getResourceModel('catalog/setup', 'catalog_setup');
97
+ }
98
+
99
+ if ($setup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, $data['code'])) {
100
+ Mage::getModel('core/config')->saveConfig($data['config_path'], $data['code']);
101
+ return $result;
102
+ }
103
+
104
+ $productTypes = array(
105
+ Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
106
+ Mage_Catalog_Model_Product_Type::TYPE_BUNDLE
107
+ );
108
+ $productTypes = join(',', $productTypes);
109
+
110
+ try {
111
+ $setup->addAttribute('catalog_product', $data['code'], array(
112
+ 'attribute_set' => $attrSet,
113
+ 'group' => $attrSetGroup,
114
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
115
+ 'type' => 'decimal',
116
+ 'input' => 'text',
117
+ 'unique' => false,
118
+ 'required' => false,
119
+ 'frontend_class' => 'validate-number',
120
+ 'class' => '',
121
+ 'apply_to' => $productTypes,
122
+ 'label' => $data['label'],
123
+ 'searchable' => false,
124
+ 'visible_in_advanced_search' => false,
125
+ 'comparable' => false,
126
+ 'filterable' => false,
127
+ 'filterable_in_search' => false,
128
+ 'used_for_promo_rules' => true,
129
+ 'html_allowed_on_front' => false,
130
+ 'visible_on_front' => false,
131
+ 'backend' => '',
132
+ 'visible' => true,
133
+ 'user_defined' => true,
134
+ 'used_in_product_listing' => false,
135
+ 'used_for_sort_by' => false
136
+ ));
137
+
138
+ Mage::getModel('core/config')->saveConfig($data['config_path'], $data['code']);
139
+ } catch (Exception $e) {
140
+ Mage::helper('shippingcore')->log($e->getMessage());
141
+ $result = false;
142
+ }
143
+
144
+ return $result;
145
+ }
146
+ }
app/code/community/Shopgo/ShippingCore/Model/Magento/Shipping/Info.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Shipping info model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_Magento_Shipping_Info extends Mage_Shipping_Model_Info
27
+ {
28
+ /**
29
+ * Get tracking info by order
30
+ *
31
+ * @return array
32
+ */
33
+ public function getTrackingInfoByOrder()
34
+ {
35
+ $shipTrack = array();
36
+ $order = $this->_initOrder();
37
+ if ($order) {
38
+ $shipments = $order->getShipmentsCollection();
39
+ foreach ($shipments as $shipment){
40
+ $increment_id = $shipment->getIncrementId();
41
+ $tracks = $shipment->getTracksCollection();
42
+
43
+ $trackingInfos = array();
44
+ foreach ($tracks as $track){
45
+ $trackingInfos[] = $track->getNumberDetail();
46
+ }
47
+
48
+ $trackingInfos = Mage::getModel('shippingcore/core')
49
+ ->processTrackingInfo(
50
+ $trackingInfos,
51
+ $order->getShippingCarrier()->getCarrierCode()
52
+ );
53
+
54
+ $shipTrack[$increment_id] = $trackingInfos;
55
+ }
56
+ }
57
+ $this->_trackingInfo = $shipTrack;
58
+ return $this->_trackingInfo;
59
+ }
60
+
61
+ /**
62
+ * Get tracking info by ship
63
+ *
64
+ * @return array
65
+ */
66
+ public function getTrackingInfoByShip()
67
+ {
68
+ $shipTrack = array();
69
+ $shipment = $this->_initShipment();
70
+ if ($shipment) {
71
+ $increment_id = $shipment->getIncrementId();
72
+ $tracks = $shipment->getTracksCollection();
73
+
74
+ $trackingInfos = array();
75
+ foreach ($tracks as $track){
76
+ $trackingInfos[] = $track->getNumberDetail();
77
+ }
78
+
79
+ $trackingInfos = Mage::getModel('shippingcore/core')
80
+ ->processTrackingInfo(
81
+ $trackingInfos,
82
+ $shipment->getOrder()->getShippingCarrier()->getCarrierCode()
83
+ );
84
+
85
+ $shipTrack[$increment_id] = $trackingInfos;
86
+
87
+ }
88
+ $this->_trackingInfo = $shipTrack;
89
+ return $this->_trackingInfo;
90
+ }
91
+
92
+ /**
93
+ * Get tracking info by track ID
94
+ *
95
+ * @return array
96
+ */
97
+ public function getTrackingInfoByTrackId()
98
+ {
99
+ $track = Mage::getModel('sales/order_shipment_track')->load($this->getTrackId());
100
+ if ($track->getId() && $this->getProtectCode() == $track->getProtectCode()) {
101
+ $this->_trackingInfo = Mage::getModel('shippingcore/core')
102
+ ->processTrackingInfoByTrackId(
103
+ $track->getNumberDetail(),
104
+ $track->getCarrierCode()
105
+ );
106
+ }
107
+ return $this->_trackingInfo;
108
+ }
109
+ }
app/code/community/Shopgo/ShippingCore/Model/Observer.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Observer model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_Observer
27
+ {
28
+ /**
29
+ * Check whether used shipment CSS and JS files
30
+ * can be included or not
31
+ *
32
+ * @param Varien_Event_Observer $observer
33
+ * @return null
34
+ */
35
+ public function setAdminSalesOrderShipmentNewCssJsFiles(Varien_Event_Observer $observer)
36
+ {
37
+ $request = Mage::app()->getRequest();
38
+ $shipment = Mage::registry('current_shipment');
39
+ $data = $observer->getEvent()->getData();
40
+ $requestPathParts = array(
41
+ 'route' => 'adminhtml',
42
+ 'controller' => 'sales_order_shipment',
43
+ 'action' => 'new'
44
+ );
45
+
46
+ //TODO: This could be implemented in a better and cleaner way
47
+ $isCorrectRequest = $request->getRouteName() != $requestPathParts['route']
48
+ || $request->getControllerName() != $requestPathParts['controller']
49
+ || $request->getActionName() != $requestPathParts['action'];
50
+
51
+ if ($isCorrectRequest
52
+ || !$data->getCheckUsedMethod()
53
+ || empty($shipment)) {
54
+ $data->setIfconfig(true);
55
+ return;
56
+ }
57
+
58
+ $carrierCode = $shipment
59
+ ->getOrder()
60
+ ->getShippingCarrier()
61
+ ->getCarrierCode();
62
+
63
+ if ($carrierCode != $data->getCheckUsedMethod()) {
64
+ $data->setIfconfig(false);
65
+ return;
66
+ }
67
+
68
+ switch (true) {
69
+ case Mage::getModel('shippingcore/carrier_aramex')->isUsed($carrierCode):
70
+ $data->setIfconfig(true);
71
+ break;
72
+ case Mage::getModel('shippingcore/carrier_skynet')->isUsed($carrierCode):
73
+ $data->setIfconfig(true);
74
+ break;
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Remove non cash on delivery methods from checkout page payment step
80
+ *
81
+ * @param Varien_Event_Observer $observer
82
+ * @return null
83
+ */
84
+ public function filterOutNonCodPaymentMethods(Varien_Event_Observer $observer)
85
+ {
86
+ $session = Mage::getSingleton('checkout/session');
87
+
88
+ if (!$session->hasQuote()) {
89
+ return;
90
+ }
91
+
92
+ $helper = Mage::helper('shippingcore');
93
+ $isUsingCod = false;
94
+
95
+ $shippingMethod = $session->getQuote()->getShippingAddress()->getShippingMethod();
96
+
97
+ $codFilteringEnabledShippingMethods = $helper->codFilteringEnabledShippingMethods();
98
+
99
+ if (!in_array($shippingMethod, $codFilteringEnabledShippingMethods)) {
100
+ return;
101
+ }
102
+
103
+ $codMethods = $helper->getCodMethodList();
104
+
105
+ $result = $observer->getEvent()->getResult();
106
+ $method = $observer->getEvent()->getMethodInstance();
107
+
108
+ $result->isAvailable =
109
+ !in_array($method->getCode(), $codMethods)
110
+ ? false : true;
111
+ }
112
+ }
app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Activepaymentmethod.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Source model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_System_Config_Source_Activepaymentmethod
27
+ {
28
+ /**
29
+ * Get active payment methods
30
+ *
31
+ * @param bool $isMultiSelect
32
+ * @return array
33
+ */
34
+ public function toOptionArray($isMultiSelect = false)
35
+ {
36
+ $options = array();
37
+ $methods = Mage::getSingleton('payment/config')->getActiveMethods();
38
+
39
+ foreach ($methods as $code => $title)
40
+ {
41
+ $title = Mage::getStoreConfig('payment/' . $code . '/title');
42
+
43
+ $options[] = array(
44
+ 'value' => $code,
45
+ 'label' => $title
46
+ );
47
+ }
48
+
49
+ if ($isMultiSelect) {
50
+ array_unshift(
51
+ $options, array(
52
+ 'value' => '',
53
+ 'label' => Mage::helper('adminhtml')->__('--Please Select--')
54
+ )
55
+ );
56
+ }
57
+
58
+ return $options;
59
+ }
60
+ }
app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Allowedcurrencies.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Source model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_System_Config_Source_Allowedcurrencies
27
+ {
28
+ /**
29
+ * CONFIG path constant: ALLOW
30
+ */
31
+ const XML_PATH_CURRENCY_ALLOW = 'currency/options/allow';
32
+
33
+
34
+ /**
35
+ * Retrieve allowed currencies according to config
36
+ *
37
+ * @return array
38
+ */
39
+ public function toOptionArray()
40
+ {
41
+ $options = array();
42
+ $allowedCurrencies = explode(
43
+ ',', Mage::getStoreConfig(self::XML_PATH_CURRENCY_ALLOW)
44
+ );
45
+ $appBaseCurrencyCode = Mage::app()->getBaseCurrencyCode();
46
+
47
+ if (!in_array($appBaseCurrencyCode, $allowedCurrencies)) {
48
+ $allowedCurrencies[] = $appBaseCurrencyCode;
49
+ }
50
+
51
+ foreach (Mage::app()->getStores() as $store) {
52
+ $code = $store->getBaseCurrencyCode();
53
+ if (!in_array($code, $allowedCurrencies)) {
54
+ $allowedCurrencies[] = $code;
55
+ }
56
+ }
57
+
58
+ foreach ($allowedCurrencies as $currency) {
59
+ $options[] = array(
60
+ 'value' => $currency,
61
+ 'label' => Mage::app()->getLocale()->currency($currency)->getName()
62
+ );
63
+ }
64
+
65
+ return $options;
66
+ }
67
+ }
app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Attributeset.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Source model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_System_Config_Source_Attributeset
27
+ {
28
+ /**
29
+ * Get attribute sets
30
+ *
31
+ * @return array
32
+ */
33
+ public function toOptionArray()
34
+ {
35
+ $entityTypeId = Mage::getModel('eav/entity')
36
+ ->setType(Mage_Catalog_Model_Product::ENTITY)->getTypeId();
37
+
38
+ $attrSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')
39
+ ->setEntityTypeFilter($entityTypeId)->load();
40
+
41
+ $options = array(
42
+ array(
43
+ 'value' => '',
44
+ 'label' => Mage::helper('adminhtml')->__('--Please Select--')
45
+ )
46
+ );
47
+
48
+ foreach ($attrSetCollection as $set) {
49
+ $options[] = array(
50
+ 'value' => $set->getAttributeSetId(),
51
+ 'label' => $set->getAttributeSetName()
52
+ );
53
+ }
54
+
55
+ return $options;
56
+ }
57
+ }
app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Attributesetgroup.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Source model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_System_Config_Source_Attributesetgroup
27
+ {
28
+ /**
29
+ * Get attribute set groups
30
+ *
31
+ * @param int $attrSet
32
+ * @return array
33
+ */
34
+ public function toOptionArray($attrSet)
35
+ {
36
+ $options = array(
37
+ array(
38
+ 'value' => '',
39
+ 'label' => Mage::helper('adminhtml')->__('--Not Specified--')
40
+ )
41
+ );
42
+
43
+ if (empty($attrSet)) {
44
+ $attrSet = Mage::getStoreConfig('shipping/dwa/attribute_set');
45
+
46
+ if (empty($attrSet)) {
47
+ return $options;
48
+ }
49
+ }
50
+
51
+ $attrSetGroupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
52
+ ->setOrder('attribute_group_id', Varien_Data_Collection::SORT_ORDER_ASC)
53
+ ->setAttributeSetFilter($attrSet)
54
+ ->load();
55
+
56
+ $options = array(
57
+ array(
58
+ 'value' => '',
59
+ 'label' => Mage::helper('adminhtml')->__('--Please Select--')
60
+ )
61
+ );
62
+
63
+ foreach ($attrSetGroupCollection as $group) {
64
+ $options[] = array(
65
+ 'value' => $group->getId(),
66
+ 'label' => $group->getAttributeGroupName()
67
+ );
68
+ }
69
+
70
+ return $options;
71
+ }
72
+ }
app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Codcurrency.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Source model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_System_Config_Source_Codcurrency
27
+ {
28
+ /**
29
+ * Base currency option value
30
+ */
31
+ const BASE = 1;
32
+
33
+ /**
34
+ * Order currency option value
35
+ */
36
+ const ORDER = 2;
37
+
38
+ /**
39
+ * Display/Currency currency option value
40
+ */
41
+ const CURRENT = 3;
42
+
43
+ /**
44
+ * Specific currency option value
45
+ */
46
+ const SPECIFIC = 4;
47
+
48
+
49
+ /**
50
+ * Get cash on delivery currency options
51
+ *
52
+ * @return array
53
+ */
54
+ public function toOptionArray()
55
+ {
56
+ $adminhtmlHelper = Mage::helper('adminhtml');
57
+
58
+ $options = array(
59
+ array(
60
+ 'value' => self::BASE,
61
+ 'label' => $adminhtmlHelper->__('Base Currency')
62
+ ),
63
+ array(
64
+ 'value' => self::ORDER,
65
+ 'label' => $adminhtmlHelper->__('Order Currency')
66
+ ),
67
+ array(
68
+ 'value' => self::CURRENT,
69
+ 'label' => $adminhtmlHelper->__('Default Display Currency')
70
+ ),
71
+ array(
72
+ 'value' => self::SPECIFIC,
73
+ 'label' => $adminhtmlHelper->__('Specific Currency')
74
+ )
75
+ );
76
+
77
+ return $options;
78
+ }
79
+ }
app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Height.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Source model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_System_Config_Source_Height
27
+ {
28
+ /**
29
+ * Get height attributes
30
+ *
31
+ * @return array
32
+ */
33
+ public function toOptionArray()
34
+ {
35
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
36
+ ->addFieldToFilter('attribute_code', array('like' => '%height%'));
37
+
38
+ $options = array(
39
+ array(
40
+ 'value' => '',
41
+ 'label' => Mage::helper('adminhtml')->__('--Please Select--')
42
+ )
43
+ );
44
+
45
+ foreach ($attributes as $attr) {
46
+ $options[] = array(
47
+ 'value' => $attr->getAttributeCode(),
48
+ 'label' => $attr->getFrontendLabel() . ' (' . $attr->getAttributeCode() . ')'
49
+ );
50
+ }
51
+
52
+ return $options;
53
+ }
54
+ }
app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Length.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Source model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_System_Config_Source_Length
27
+ {
28
+ /**
29
+ * Get length attributes
30
+ *
31
+ * @return array
32
+ */
33
+ public function toOptionArray()
34
+ {
35
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
36
+ ->addFieldToFilter('attribute_code', array('like' => '%length%'));
37
+
38
+ $options = array(
39
+ array(
40
+ 'value' => '',
41
+ 'label' => Mage::helper('adminhtml')->__('--Please Select--')
42
+ )
43
+ );
44
+
45
+ foreach ($attributes as $attr) {
46
+ $options[] = array(
47
+ 'value' => $attr->getAttributeCode(),
48
+ 'label' => $attr->getFrontendLabel() . ' (' . $attr->getAttributeCode() . ')'
49
+ );
50
+ }
51
+
52
+ return $options;
53
+ }
54
+ }
app/code/community/Shopgo/ShippingCore/Model/System/Config/Source/Width.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Source model
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Model_System_Config_Source_Width
27
+ {
28
+ /**
29
+ * Get width attributes
30
+ *
31
+ * @return array
32
+ */
33
+ public function toOptionArray()
34
+ {
35
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
36
+ ->addFieldToFilter('attribute_code', array('like' => '%width%'));
37
+
38
+ $options = array(
39
+ array(
40
+ 'value' => '',
41
+ 'label' => Mage::helper('adminhtml')->__('--Please Select--')
42
+ )
43
+ );
44
+
45
+ foreach ($attributes as $attr) {
46
+ $options[] = array(
47
+ 'value' => $attr->getAttributeCode(),
48
+ 'label' => $attr->getFrontendLabel() . ' (' . $attr->getAttributeCode() . ')'
49
+ );
50
+ }
51
+
52
+ return $options;
53
+ }
54
+ }
app/code/community/Shopgo/ShippingCore/controllers/Adminhtml/Sales/Order/ShipmentController.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Adminhtml shipment controller
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ require_once 'Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php';
27
+
28
+ class Shopgo_ShippingCore_Adminhtml_Sales_Order_ShipmentController extends Mage_Adminhtml_Sales_Order_ShipmentController
29
+ {
30
+ /**
31
+ * Save shipment
32
+ * We can save only new shipment. Existing shipments are not editable
33
+ *
34
+ * @return null
35
+ */
36
+ public function saveAction()
37
+ {
38
+ $data = $this->getRequest()->getPost('shipment');
39
+ if (!empty($data['comment_text'])) {
40
+ Mage::getSingleton('adminhtml/session')->setCommentText($data['comment_text']);
41
+ }
42
+
43
+ try {
44
+ $shipment = $this->_initShipment();
45
+ if (!$shipment) {
46
+ $this->_forward('noRoute');
47
+ return;
48
+ }
49
+
50
+ $shipment->register();
51
+ $comment = '';
52
+ if (!empty($data['comment_text'])) {
53
+ $shipment->addComment(
54
+ $data['comment_text'],
55
+ isset($data['comment_customer_notify']),
56
+ isset($data['is_visible_on_front'])
57
+ );
58
+ if (isset($data['comment_customer_notify'])) {
59
+ $comment = $data['comment_text'];
60
+ }
61
+ }
62
+
63
+ if (!empty($data['send_email'])) {
64
+ $shipment->setEmailSent(true);
65
+ }
66
+
67
+ $shipment->getOrder()->setCustomerNoteNotify(!empty($data['send_email']));
68
+ $responseAjax = new Varien_Object();
69
+ $isNeedCreateLabel = isset($data['create_shipping_label']) && $data['create_shipping_label'];
70
+
71
+ if ($isNeedCreateLabel && $this->_createShippingLabel($shipment)) {
72
+ $responseAjax->setOk(true);
73
+ }
74
+
75
+ $isShopgoShippingMethod = Mage::helper('shippingcore')->isShopgoShippingMethod(
76
+ $shipment->getOrder()->getShippingCarrier()->getCarrierCode()
77
+ );
78
+
79
+ if ($isShopgoShippingMethod) {
80
+ $shippingCoreResult = Mage::getModel('shippingcore/core')->saveShipment(
81
+ $shipment,
82
+ $this->getRequest()->getPost('shopgo')
83
+ );
84
+
85
+ if (!$shippingCoreResult) {
86
+ Mage::throwException($this->__('Cannot save shipment.'));
87
+ }
88
+ } else {
89
+ $this->_saveShipment($shipment);
90
+
91
+ $shipment->sendEmail(!empty($data['send_email']), $comment);
92
+ }
93
+
94
+ $shipmentCreatedMessage = $this->__('The shipment has been created.');
95
+ $labelCreatedMessage = $this->__('The shipping label has been created.');
96
+
97
+ $this->_getSession()->addSuccess($isNeedCreateLabel ? $shipmentCreatedMessage . ' ' . $labelCreatedMessage
98
+ : $shipmentCreatedMessage);
99
+ Mage::getSingleton('adminhtml/session')->getCommentText(true);
100
+ } catch (Mage_Core_Exception $e) {
101
+ if ($isNeedCreateLabel) {
102
+ $responseAjax->setError(true);
103
+ $responseAjax->setMessage($e->getMessage());
104
+ } else {
105
+ $this->_getSession()->addError($e->getMessage());
106
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
107
+ }
108
+ } catch (Exception $e) {
109
+ Mage::logException($e);
110
+ if ($isNeedCreateLabel) {
111
+ $responseAjax->setError(true);
112
+ $responseAjax->setMessage(
113
+ Mage::helper('sales')->__('An error occurred while creating shipping label.'));
114
+ } else {
115
+ $this->_getSession()->addError($this->__('Cannot save shipment.'));
116
+ $this->_redirect('*/*/new', array('order_id' => $this->getRequest()->getParam('order_id')));
117
+ }
118
+
119
+ }
120
+ if ($isNeedCreateLabel) {
121
+ $this->getResponse()->setBody($responseAjax->toJson());
122
+ } else {
123
+ $this->_redirect('*/sales_order/view', array('order_id' => $shipment->getOrderId()));
124
+ }
125
+ }
126
+ }
app/code/community/Shopgo/ShippingCore/controllers/Adminhtml/Shopgo/ShippingcoreController.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
15
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
16
+ */
17
+
18
+
19
+ /**
20
+ * Adminhtml shipping core controller
21
+ *
22
+ * @category Shopgo
23
+ * @package Shopgo_ShippingCore
24
+ * @author Ammar <ammar@shopgo.me>
25
+ */
26
+ class Shopgo_ShippingCore_Adminhtml_Shopgo_ShippingcoreController extends Mage_Adminhtml_Controller_Action
27
+ {
28
+ /**
29
+ * Set dimensional weight attributes
30
+ *
31
+ * @return string
32
+ */
33
+ public function setDwAttributesAction()
34
+ {
35
+ $params = $this->getRequest()->getPost();
36
+ $response = Mage::app()->getResponse()
37
+ ->setHeader('content-type', 'application/json; charset=utf-8');
38
+
39
+ $result = array(
40
+ 'status' => 0,
41
+ 'description' => $this->__('Unspecified error')
42
+ );
43
+
44
+ $_result = Mage::getModel('shippingcore/dwa')->setDwAttributes(
45
+ $params['attribute_set'],
46
+ $params['attribute_set_group']
47
+ );
48
+
49
+ if ($_result) {
50
+ $result = array(
51
+ 'status' => 1,
52
+ 'description' => ''
53
+ );
54
+ } else {
55
+ $result['description'] = $this->__('Could not set dimensional weight attributes! Please try to set them manually.');
56
+ }
57
+
58
+ $response->setBody(json_encode($result));
59
+ }
60
+
61
+ /**
62
+ * Get dimensional weight attribute set groups
63
+ *
64
+ * @return string
65
+ */
66
+ public function getDwaSetGroupsAction()
67
+ {
68
+ $params = $this->getRequest()->getPost();
69
+ $response = Mage::app()->getResponse()
70
+ ->setHeader('content-type', 'application/json; charset=utf-8');
71
+
72
+ $result = array(
73
+ 'status' => 0,
74
+ 'description' => $this->__('Unspecified error')
75
+ );
76
+
77
+ if (!isset($params['attribute_set'])) {
78
+ $result['description'] = '';
79
+ $response->setBody(json_encode($result));
80
+
81
+ return;
82
+ }
83
+
84
+ $groups = Mage::getModel('shippingcore/system_config_source_attributesetgroup')
85
+ ->toOptionArray($params['attribute_set']);
86
+
87
+ if (!empty($groups)) {
88
+ $result = array(
89
+ 'status' => 1,
90
+ 'description' => '',
91
+ 'data' => $groups
92
+ );
93
+ } else {
94
+ $result['description'] = $this->__('Could not get the groups for the specified attribute set!');
95
+ }
96
+
97
+ $response->setBody(json_encode($result));
98
+ }
99
+ }
app/code/community/Shopgo/ShippingCore/etc/adminhtml.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ShopGo
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
+ *
13
+ * @category Shopgo
14
+ * @package Shopgo_ShippingCore
15
+ * @author Ammar <ammar@shopgo.me>
16
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
17
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
18
+ */
19
+ -->
20
+ <config>
21
+ <menu>
22
+ <shopgo translate="title" module="shippingcore">
23
+ <title>ShopGo</title>
24
+ <sort_order>71</sort_order>
25
+ <children>
26
+ <shippingcore translate="title" module="shippingcore">
27
+ <title>Shipping Methods</title>
28
+ <sort_order>10</sort_order>
29
+ <children>
30
+ <shipping_methods translate="title" module="shippingcore">
31
+ <title>General</title>
32
+ <sort_order>10</sort_order>
33
+ <children>
34
+ <shipping_settings translate="title" module="shippingcore">
35
+ <title>Shipping Settings</title>
36
+ <sort_order>10</sort_order>
37
+ <action>adminhtml/system_config/edit/section/shipping</action>
38
+ </shipping_settings>
39
+ <methods_configurations translate="title" module="shippingcore">
40
+ <title>Methods Configurations</title>
41
+ <sort_order>20</sort_order>
42
+ <action>adminhtml/system_config/edit/section/carriers</action>
43
+ </methods_configurations>
44
+ </children>
45
+ </shipping_methods>
46
+ </children>
47
+ </shippingcore>
48
+ </children>
49
+ </shopgo>
50
+ </menu>
51
+ <acl>
52
+ <resources>
53
+ <admin>
54
+ <children>
55
+ <shopgo translate="title" module="shippingcore">
56
+ <title>ShopGo</title>
57
+ <sort_order>71</sort_order>
58
+ <children>
59
+ <shippingcore translate="title" module="shippingcore">
60
+ <title>Shipping Methods</title>
61
+ <sort_order>10</sort_order>
62
+ <children>
63
+ <shipping_methods translate="title" module="shippingcore">
64
+ <title>General</title>
65
+ <sort_order>10</sort_order>
66
+ <children>
67
+ <shipping_settings translate="title" module="shippingcore">
68
+ <title>Shipping Settings</title>
69
+ <sort_order>10</sort_order>
70
+ </shipping_settings>
71
+ <methods_configurations translate="title" module="shippingcore">
72
+ <title>Methods Configurations</title>
73
+ <sort_order>20</sort_order>
74
+ </methods_configurations>
75
+ </children>
76
+ </shipping_methods>
77
+ </children>
78
+ </shippingcore>
79
+ </children>
80
+ </shopgo>
81
+ </children>
82
+ </admin>
83
+ </resources>
84
+ </acl>
85
+ </config>
app/code/community/Shopgo/ShippingCore/etc/config.xml ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ShopGo
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
+ *
13
+ * @category Shopgo
14
+ * @package Shopgo_ShippingCore
15
+ * @author Ammar <ammar@shopgo.me>
16
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
17
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
18
+ */
19
+ -->
20
+ <config>
21
+ <modules>
22
+ <Shopgo_ShippingCore>
23
+ <version>1.3.7</version>
24
+ </Shopgo_ShippingCore>
25
+ </modules>
26
+ <global>
27
+ <blocks>
28
+ <shippingcore>
29
+ <class>Shopgo_ShippingCore_Block</class>
30
+ </shippingcore>
31
+ </blocks>
32
+ <helpers>
33
+ <shippingcore>
34
+ <class>Shopgo_ShippingCore_Helper</class>
35
+ </shippingcore>
36
+ </helpers>
37
+ <models>
38
+ <shippingcore>
39
+ <class>Shopgo_ShippingCore_Model</class>
40
+ </shippingcore>
41
+ <shipping>
42
+ <rewrite>
43
+ <info>Shopgo_ShippingCore_Model_Magento_Shipping_Info</info>
44
+ </rewrite>
45
+ </shipping>
46
+ </models>
47
+ <resources>
48
+ <shippingcore_setup>
49
+ <setup>
50
+ <module>Shopgo_ShippingCore</module>
51
+ <class>Mage_Catalog_Model_Resource_Setup</class>
52
+ </setup>
53
+ </shippingcore_setup>
54
+ </resources>
55
+ <events>
56
+ <adv_ifconfig_custom_rules>
57
+ <observers>
58
+ <set_admin_sales_order_shipment_new_css_js_files>
59
+ <type>singleton</type>
60
+ <class>shippingcore/observer</class>
61
+ <method>setAdminSalesOrderShipmentNewCssJsFiles</method>
62
+ </set_admin_sales_order_shipment_new_css_js_files>
63
+ </observers>
64
+ </adv_ifconfig_custom_rules>
65
+ <payment_method_is_active>
66
+ <observers>
67
+ <filter_out_non_cod_payment_methods>
68
+ <type>singleton</type>
69
+ <class>shippingcore/observer</class>
70
+ <method>filterOutNonCodPaymentMethods</method>
71
+ </filter_out_non_cod_payment_methods>
72
+ </observers>
73
+ </payment_method_is_active>
74
+ </events>
75
+ </global>
76
+ <frontend>
77
+ <layout>
78
+ <updates>
79
+ <shippingcore>
80
+ <file>shopgo/shipping_core.xml</file>
81
+ </shippingcore>
82
+ </updates>
83
+ </layout>
84
+ </frontend>
85
+ <admin>
86
+ <routers>
87
+ <adminhtml>
88
+ <args>
89
+ <modules>
90
+ <shippingcore before="Mage_Adminhtml">Shopgo_ShippingCore_Adminhtml</shippingcore>
91
+ </modules>
92
+ </args>
93
+ </adminhtml>
94
+ </routers>
95
+ </admin>
96
+ <adminhtml>
97
+ <layout>
98
+ <updates>
99
+ <shippingcore>
100
+ <file>shopgo/shipping_core.xml</file>
101
+ </shippingcore>
102
+ </updates>
103
+ </layout>
104
+ </adminhtml>
105
+ </config>
app/code/community/Shopgo/ShippingCore/etc/system.xml ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * ShopGo
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
+ *
13
+ * @category Shopgo
14
+ * @package Shopgo_ShippingCore
15
+ * @author Ammar <ammar@shopgo.me>
16
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
17
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
18
+ */
19
+ -->
20
+ <config>
21
+ <sections>
22
+ <shipping translate="label" module="shippingcore">
23
+ <groups>
24
+ <origin translate="label">
25
+ <fields>
26
+ <street_line3 translate="label">
27
+ <label>Street Address Line 3</label>
28
+ <frontend_type>text</frontend_type>
29
+ <sort_order>70</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>0</show_in_store>
33
+ </street_line3>
34
+ </fields>
35
+ </origin>
36
+ <additional_info translate="label">
37
+ <label>Additional Info</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>3</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <fields>
44
+ <person_title translate="label">
45
+ <label>Person Title</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>10</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>0</show_in_store>
51
+ </person_title>
52
+ <person_name translate="label">
53
+ <label>Person Name</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>20</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ </person_name>
60
+ <company translate="label">
61
+ <label>Company</label>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>30</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>0</show_in_store>
67
+ </company>
68
+ <store_description translate="label">
69
+ <label>Store Description</label>
70
+ <frontend_type>text</frontend_type>
71
+ <sort_order>40</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>0</show_in_store>
75
+ </store_description>
76
+ <phone_number translate="label">
77
+ <label>Phone Number</label>
78
+ <frontend_type>text</frontend_type>
79
+ <sort_order>50</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ </phone_number>
84
+ <phone_number_ext translate="label">
85
+ <label>Phone Number Ext</label>
86
+ <frontend_type>text</frontend_type>
87
+ <sort_order>60</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ </phone_number_ext>
92
+ <phone_number2 translate="label">
93
+ <label>Phone Number 2</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>70</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
+ </phone_number2>
100
+ <phone_number2_ext translate="label">
101
+ <label>Phone Number 2 Ext</label>
102
+ <frontend_type>text</frontend_type>
103
+ <sort_order>80</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>0</show_in_store>
107
+ </phone_number2_ext>
108
+ <faxnumber translate="label">
109
+ <label>Fax Number</label>
110
+ <frontend_type>text</frontend_type>
111
+ <sort_order>90</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>0</show_in_store>
115
+ </faxnumber>
116
+ <email translate="label">
117
+ <label>Email</label>
118
+ <frontend_type>text</frontend_type>
119
+ <sort_order>100</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>0</show_in_store>
123
+ </email>
124
+ <cellphone translate="label">
125
+ <label>Cellphone</label>
126
+ <frontend_type>text</frontend_type>
127
+ <sort_order>110</sort_order>
128
+ <show_in_default>1</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>0</show_in_store>
131
+ </cellphone>
132
+ </fields>
133
+ </additional_info>
134
+ <dwa translate="label">
135
+ <label>Dimensional Weight Attributes</label>
136
+ <frontend_type>text</frontend_type>
137
+ <sort_order>4</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ <fields>
142
+ <length translate="label">
143
+ <label>Length</label>
144
+ <frontend_type>select</frontend_type>
145
+ <source_model>shippingcore/system_config_source_length</source_model>
146
+ <sort_order>10</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>0</show_in_store>
150
+ </length>
151
+ <width translate="label">
152
+ <label>Width</label>
153
+ <frontend_type>select</frontend_type>
154
+ <source_model>shippingcore/system_config_source_width</source_model>
155
+ <sort_order>20</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>0</show_in_store>
159
+ </width>
160
+ <height translate="label">
161
+ <label>Height</label>
162
+ <frontend_type>select</frontend_type>
163
+ <source_model>shippingcore/system_config_source_height</source_model>
164
+ <sort_order>30</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>0</show_in_store>
168
+ </height>
169
+ <separator translate="label">
170
+ <frontend_type>hidden</frontend_type>
171
+ <sort_order>40</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>0</show_in_store>
175
+ </separator>
176
+ <attribute_set translate="label">
177
+ <label>Attribute Set</label>
178
+ <frontend_type>select</frontend_type>
179
+ <source_model>shippingcore/system_config_source_attributeset</source_model>
180
+ <sort_order>50</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>0</show_in_store>
184
+ </attribute_set>
185
+ <attribute_set_group translate="label comment">
186
+ <label>Attribute Set Group</label>
187
+ <frontend_type>select</frontend_type>
188
+ <comment><![CDATA[
189
+ <strong style="color:#3D5B9C">Note:&nbsp;</strong>Attribute set and attrbute set group are optional and only used to set dimensional weight attributes.
190
+ ]]></comment>
191
+ <source_model>shippingcore/system_config_source_attributesetgroup</source_model>
192
+ <sort_order>60</sort_order>
193
+ <show_in_default>1</show_in_default>
194
+ <show_in_website>1</show_in_website>
195
+ <show_in_store>0</show_in_store>
196
+ </attribute_set_group>
197
+ <set_attributes translate="label">
198
+ <frontend_type>button</frontend_type>
199
+ <frontend_model>shippingcore/adminhtml_system_config_form_dwaButton</frontend_model>
200
+ <sort_order>70</sort_order>
201
+ <show_in_default>1</show_in_default>
202
+ <show_in_website>1</show_in_website>
203
+ <show_in_store>0</show_in_store>
204
+ </set_attributes>
205
+ </fields>
206
+ </dwa>
207
+ <cod>
208
+ <label>Cash on Delivery</label>
209
+ <frontend_type>text</frontend_type>
210
+ <sort_order>5</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>1</show_in_store>
214
+ <fields>
215
+ <payment_methods translate="label comment">
216
+ <label>Payment Methods</label>
217
+ <comment><![CDATA[
218
+ Select Cash on Delivery methods from the above active payment methods list.<br/>
219
+ <strong style="color:#3D5B9C">Note:&nbsp;</strong>Make sure that the COD payment methods that you want to select are enabled in (System > Configuration > Payment Methods page).
220
+ ]]></comment>
221
+ <frontend_type>multiselect</frontend_type>
222
+ <sort_order>10</sort_order>
223
+ <source_model>shippingcore/system_config_source_activepaymentmethod</source_model>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>0</show_in_store>
227
+ </payment_methods>
228
+ <currency translate="label">
229
+ <label>Currency</label>
230
+ <frontend_type>select</frontend_type>
231
+ <source_model>shippingcore/system_config_source_codcurrency</source_model>
232
+ <sort_order>20</sort_order>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>0</show_in_store>
236
+ </currency>
237
+ <specific_currency translate="label comment">
238
+ <label>Specific Currency</label>
239
+ <comment><![CDATA[
240
+ You can add more currencies to the list from (System > Configuration > General > Currency Setup > Currency Options > Allowed Currencies).<br/>
241
+ <strong style="color:#3D5B9C">Note:&nbsp;</strong>In case that the selected currency got removed from allowed currencies, you would have to specify another one. Otherwise, the base currency will be selected by default.
242
+ ]]></comment>
243
+ <frontend_type>select</frontend_type>
244
+ <source_model>shippingcore/system_config_source_allowedcurrencies</source_model>
245
+ <sort_order>30</sort_order>
246
+ <show_in_default>1</show_in_default>
247
+ <show_in_website>1</show_in_website>
248
+ <show_in_store>0</show_in_store>
249
+ <depends><currency>4</currency></depends>
250
+ </specific_currency>
251
+ </fields>
252
+ </cod>
253
+ </groups>
254
+ </shipping>
255
+ </sections>
256
+ </config>
app/code/community/Shopgo/ShippingCore/sql/shippingcore_setup/mysql4-install-1.1.2.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
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
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @author Ammar <ammar@shopgo.me>
15
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+
20
+ /* @var $installer Mage_Catalog_Model_Resource_Setup */
21
+ $installer = $this;
22
+
23
+ $installer->startSetup();
24
+
25
+ /**
26
+ * Add dimensional weight attributes
27
+ */
28
+ Mage::getModel('shippingcore/dwa')->setDwAttributes('', '', $installer);
29
+
30
+ $productTypes = array(
31
+ Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
32
+ Mage_Catalog_Model_Product_Type::TYPE_BUNDLE
33
+ );
34
+ $productTypes = join(',', $productTypes);
35
+
36
+ /**
37
+ * Add harmonized system code attribute
38
+ */
39
+ $installer->addAttribute('catalog_product', 'hs_code', array(
40
+ 'attribute_set' => 'Default',
41
+ 'group' => 'General',
42
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
43
+ 'type' => 'varchar',
44
+ 'input' => 'text',
45
+ 'unique' => false,
46
+ 'required' => false,
47
+ 'class' => '',
48
+ 'apply_to' => $productTypes,
49
+ 'label' => 'HS Code',
50
+ 'searchable' => true,
51
+ 'visible_in_advanced_search' => true,
52
+ 'comparable' => true,
53
+ 'filterable' => false,
54
+ 'filterable_in_search' => false,
55
+ 'used_for_promo_rules' => true,
56
+ 'html_allowed_on_front' => false,
57
+ 'visible_on_front' => false,
58
+ 'backend' => '',
59
+ 'visible' => true,
60
+ 'user_defined' => true,
61
+ 'used_in_product_listing' => false,
62
+ 'used_for_sort_by' => false
63
+ ));
64
+
65
+ $installer->endSetup();
app/design/frontend/base/default/template/shopgo/shipping_core/checkout/cart/shipping.phtml ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ShopGo
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ *
12
+ * @category Shopgo
13
+ * @package Shopgo_ShippingCore
14
+ * @author Ammar <ammar@shopgo.me>
15
+ * @copyright Copyright (c) 2014 Shopgo. (http://www.shopgo.me)
16
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
17
+ */
18
+ ?>
19
+ <?php /** @var $this Mage_Checkout_Block_Cart_Shipping */ ?>
20
+ <div class="shipping">
21
+ <h2><?php echo $this->__('Estimate Shipping and Tax') ?></h2>
22
+ <div class="shipping-form">
23
+ <form action="<?php echo $this->getUrl('checkout/cart/estimatePost') ?>" method="post" id="shipping-zip-form">
24
+ <p><?php echo $this->__('Enter your destination to get a shipping estimate.') ?></p>
25
+ <ul class="form-list">
26
+ <li>
27
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
28
+ <div class="input-box">
29
+ <?php echo Mage::getBlockSingleton('directory/data')->getCountryHtmlSelect($this->getEstimateCountryId()) ?>
30
+ </div>
31
+ </li>
32
+ <?php //if($this->getStateActive()): ?>
33
+ <li>
34
+ <label for="region_id"<?php if ($this->isStateProvinceRequired()) echo ' class="required"' ?>><?php if ($this->isStateProvinceRequired()) echo '<em>*</em>' ?><?php echo $this->__('State/Province') ?></label>
35
+ <div class="input-box">
36
+ <select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" style="display:none;"<?php echo ($this->isStateProvinceRequired() ? ' class="validate-select"' : '') ?>>
37
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
38
+ </select>
39
+ <script type="text/javascript">
40
+ //<![CDATA[
41
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getEstimateRegionId() ?>");
42
+ //]]>
43
+ </script>
44
+ <input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getEstimateRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
45
+ </div>
46
+ </li>
47
+ <?php //endif; ?>
48
+ <?php //if($this->getCityActive()): ?>
49
+ <li>
50
+ <label for="city"<?php if ($this->isCityRequired()) echo ' class="required"' ?>><?php if ($this->isCityRequired()) echo '<em>*</em>' ?><?php echo $this->__('City') ?></label>
51
+ <div class="input-box">
52
+ <input class="input-text<?php if ($this->isCityRequired()):?> required-entry<?php endif;?>" id="city" type="text" name="estimate_city" value="<?php echo $this->escapeHtml($this->getEstimateCity()) ?>" />
53
+ </div>
54
+ </li>
55
+ <?php //endif; ?>
56
+ <li>
57
+ <label for="postcode"<?php if ($this->isZipCodeRequired()) echo ' class="required"' ?>><?php if ($this->isZipCodeRequired()) echo '<em>*</em>' ?><?php echo $this->__('Zip/Postal Code') ?></label>
58
+ <div class="input-box">
59
+ <input class="input-text validate-postcode<?php if ($this->isZipCodeRequired()):?> required-entry<?php endif;?>" type="text" id="postcode" name="estimate_postcode" value="<?php echo $this->escapeHtml($this->getEstimatePostcode()) ?>" />
60
+ </div>
61
+ </li>
62
+ </ul>
63
+ <div class="buttons-set">
64
+ <button type="button" title="<?php echo $this->__('Get a Quote') ?>" onclick="coShippingMethodForm.submit()" class="button"><span><span><?php echo $this->__('Get a Quote') ?></span></span></button>
65
+ </div>
66
+ </form>
67
+ <script type="text/javascript">
68
+ //<![CDATA[
69
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
70
+ //]]>
71
+ </script>
72
+
73
+ <?php if (($_shippingRateGroups = $this->getEstimateRates())): ?>
74
+ <form id="co-shipping-method-form" action="<?php echo $this->getUrl('checkout/cart/estimateUpdatePost') ?>">
75
+ <dl class="sp-methods">
76
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
77
+ <dt><?php echo $this->escapeHtml($this->getCarrierName($code)) ?></dt>
78
+ <dd>
79
+ <ul>
80
+ <?php foreach ($_rates as $_rate): ?>
81
+ <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"';?>>
82
+ <?php if ($_rate->getErrorMessage()): ?>
83
+ <?php echo $this->escapeHtml($_rate->getErrorMessage()) ?>
84
+ <?php else: ?>
85
+ <input name="estimate_method" type="radio" value="<?php echo $this->escapeHtml($_rate->getCode()) ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio" />
86
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $this->escapeHtml($_rate->getMethodTitle()) ?>
87
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
88
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
89
+ <?php echo $_excl; ?>
90
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
91
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
92
+ <?php endif; ?>
93
+ </label>
94
+ <?php endif ?>
95
+ </li>
96
+ <?php endforeach; ?>
97
+ </ul>
98
+ </dd>
99
+ <?php endforeach; ?>
100
+ </dl>
101
+ <div class="buttons-set">
102
+ <button type="submit" title="<?php echo $this->__('Update Total') ?>" class="button" name="do" value="<?php echo $this->__('Update Total') ?>"><span><span><?php echo $this->__('Update Total') ?></span></span></button>
103
+ </div>
104
+ </form>
105
+ <?php endif; ?>
106
+ <script type="text/javascript">
107
+ //<![CDATA[
108
+ var coShippingMethodForm = new VarienForm('shipping-zip-form');
109
+ var countriesWithOptionalZip = <?php echo $this->helper('directory')->getCountriesWithOptionalZip(true) ?>;
110
+
111
+ coShippingMethodForm.submit = function () {
112
+ var country = $F('country');
113
+ var optionalZip = false;
114
+
115
+ for (i=0; i < countriesWithOptionalZip.length; i++) {
116
+ if (countriesWithOptionalZip[i] == country) {
117
+ optionalZip = true;
118
+ }
119
+ }
120
+ if (optionalZip) {
121
+ $('postcode').removeClassName('required-entry');
122
+ }
123
+ else {
124
+ $('postcode').addClassName('required-entry');
125
+ }
126
+ return VarienForm.prototype.submit.bind(coShippingMethodForm)();
127
+ }
128
+ //]]>
129
+ </script>
130
+ </div>
131
+ </div>
package.xml CHANGED
@@ -1,20 +1,21 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Shopgo_ShippingCore</name>
4
- <version>1.3.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>A shipping core module that other ShopGo shipping modules depend on.</summary>
10
  <description>&lt;p&gt;ShopGo Shipping Core is a utility module that contains functions used by other ShopGo shipping modules.&lt;/p&gt;&#xD;
 
11
  You could also get the latest version of the module from:&#xD;
12
  &lt;a href="https://github.com/shopgo-me/shipping-core"&gt;https://github.com/shopgo-me/shipping-core&lt;/a&gt;</description>
13
- <notes>The first release of ShopGo Core module.</notes>
14
  <authors><author><name>ShopGo</name><user>ShopGo</user><email>support@shopgo.me</email></author></authors>
15
- <date>2015-07-08</date>
16
- <time>14:20:13</time>
17
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="shopgo"><file name="shipping_core.xml" hash="be6da9a49309d76666e521f5f9838a96"/></dir></dir><dir name="template"><dir name="shopgo"><dir name="shipping_core"><dir name="sales"><dir name="order"><dir name="shipment"><dir name="create"><file name="form.phtml" hash="f5ab96dfcd5996b66a89a059882a596e"/><file name="items.phtml" hash="4a00a29303c47c91fa83afcbb29935c7"/></dir></dir></dir></dir><dir name="system"><dir name="config"><file name="dwa_button.phtml" hash="706179d3120c218faf9a1e815642394b"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="shopgo"><file name="shipping_core.xml" hash="fe05da7d61e0d6392654981524b3c91e"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shopgo_ShippingCore.xml" hash="74b12adf823de62e688e8452525304f7"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php><package><name>Shopgo_Core</name><channel>community</channel><min>1.0.6</min><max/></package><package><name>Shopgo_AdvIfconfig</name><channel>community</channel><min>1.0.3</min><max/></package></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Shopgo_ShippingCore</name>
4
+ <version>1.3.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>A shipping core module that other ShopGo shipping modules depend on. It contains reusable code functions.</summary>
10
  <description>&lt;p&gt;ShopGo Shipping Core is a utility module that contains functions used by other ShopGo shipping modules.&lt;/p&gt;&#xD;
11
+ &lt;p&gt;This module combines all ShopGo's shipping modules shared/reusable code in one place, in order to reduce code redundancy and the number of conflicts between some modules (Especially shipping ones).&lt;/p&gt;&#xD;
12
  You could also get the latest version of the module from:&#xD;
13
  &lt;a href="https://github.com/shopgo-me/shipping-core"&gt;https://github.com/shopgo-me/shipping-core&lt;/a&gt;</description>
14
+ <notes>The first release of ShopGo Shipping Core module.</notes>
15
  <authors><author><name>ShopGo</name><user>ShopGo</user><email>support@shopgo.me</email></author></authors>
16
+ <date>2015-07-09</date>
17
+ <time>22:25:33</time>
18
+ <contents><target name="magecommunity"><dir name="Shopgo"><dir name="ShippingCore"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="DwaButton.php" hash="f92bf59b64d4ab8ff65313effc8fbfd5"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Abstract.php" hash="cf1d76cc4e397b20437387e68ea850cb"/><file name="Data.php" hash="79ad030f4b4455e85bb766c432f6778b"/></dir><dir name="Model"><dir name="Carrier"><file name="Abstract.php" hash="e21fa98a3a4311c82d91d8009e70c56d"/><file name="Aramex.php" hash="61cc9e68243496863866a4fc0c6faa53"/><file name="Skynet.php" hash="2c149c343e522c87da941351e4202cdd"/></dir><file name="Core.php" hash="f895741166d0e6bc6264a80ca7edb46a"/><file name="Dwa.php" hash="d0f17e5e5dbc058e9f140409af31ee50"/><dir name="Magento"><dir name="Shipping"><file name="Info.php" hash="77708e567685d0dd94f31b9b43ec0ce7"/></dir></dir><file name="Observer.php" hash="b42b6fa0a958a1eb11fad4b3aa31d939"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Activepaymentmethod.php" hash="14545cdd75cf2ff4138a19ab0cdae3b6"/><file name="Allowedcurrencies.php" hash="4b7776c0f674d39c6e9adddcb7d53234"/><file name="Attributeset.php" hash="4e764d2b2be458151e381f2b1e7cabc6"/><file name="Attributesetgroup.php" hash="9e3e6b25951acdb014d6e9d7633bb709"/><file name="Codcurrency.php" hash="d41fc6f0acf1ecf4c39802545610b338"/><file name="Height.php" hash="385876f1fc49747d49d45f8ad7ebe35c"/><file name="Length.php" hash="a94e492f1e97a835d5a4161973a9c919"/><file name="Width.php" hash="73e3ed9364e5e347b9e38a2f7b838562"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="ShipmentController.php" hash="4167c3313c46c23d9d0a717cc8062b59"/></dir></dir><dir name="Shopgo"><file name="ShippingcoreController.php" hash="590ec968bb5b6daebd0c640826b55ea2"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="92557f6dbe9747c0da89eb1ee8ffbb7c"/><file name="config.xml" hash="ef730c677ced947d1e47d8b1e684d48b"/><file name="system.xml" hash="bdc72b68e16ede0c6a9a1d96d2860f7c"/></dir><dir name="sql"><dir name="shippingcore_setup"><file name="mysql4-install-1.1.2.php" hash="9bee70d471520da341081b267633987c"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="shopgo"><file name="shipping_core.xml" hash="be6da9a49309d76666e521f5f9838a96"/></dir></dir><dir name="template"><dir name="shopgo"><dir name="shipping_core"><dir name="sales"><dir name="order"><dir name="shipment"><dir name="create"><file name="form.phtml" hash="f5ab96dfcd5996b66a89a059882a596e"/><file name="items.phtml" hash="4a00a29303c47c91fa83afcbb29935c7"/></dir></dir></dir></dir><dir name="system"><dir name="config"><file name="dwa_button.phtml" hash="706179d3120c218faf9a1e815642394b"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="shopgo"><file name="shipping_core.xml" hash="fe05da7d61e0d6392654981524b3c91e"/></dir></dir><dir name="template"><dir name="shopgo"><dir name="shipping_core"><dir name="checkout"><dir name="cart"><file name="shipping.phtml" hash="fd2b00efe72f6ff91eb77076ceaafc51"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shopgo_ShippingCore.xml" hash="74b12adf823de62e688e8452525304f7"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php><package><name>Shopgo_Core</name><channel>community</channel><min>1.0.6</min><max/></package><package><name>Shopgo_AdvIfconfig</name><channel>community</channel><min>1.0.3</min><max/></package></required></dependencies>
21
  </package>