ShipHawk - Version 1.0.0

Version Notes

v1.0.0 is ShipHawk's initial production release for Magento clients that allows interaction with ShipHawk test and production environments.

Download this release

Release Info

Developer Mr. Shiphawk
Extension ShipHawk
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (26) hide show
  1. app/code/community/Shiphawk/Shipping/Block/Adminhtml/Sales/Order/Shipment/View.php +20 -0
  2. app/code/community/Shiphawk/Shipping/Block/Adminhtml/Sales/Order/View.php +31 -0
  3. app/code/community/Shiphawk/Shipping/Block/Catalog/Product/Helper/Form/Disabled.php +14 -0
  4. app/code/community/Shiphawk/Shipping/Block/Catalog/Product/Helper/Form/Type.php +64 -0
  5. app/code/community/Shiphawk/Shipping/Helper/Data.php +73 -0
  6. app/code/community/Shiphawk/Shipping/Model/Api.php +310 -0
  7. app/code/community/Shiphawk/Shipping/Model/Carrier.php +283 -0
  8. app/code/community/Shiphawk/Shipping/Model/Observer.php +78 -0
  9. app/code/community/Shiphawk/Shipping/Model/Product/Attribute/Source/Location.php +25 -0
  10. app/code/community/Shiphawk/Shipping/Model/Source/Gateway.php +11 -0
  11. app/code/community/Shiphawk/Shipping/Model/Source/Location.php +11 -0
  12. app/code/community/Shiphawk/Shipping/Model/Source/Ratefilter.php +11 -0
  13. app/code/community/Shiphawk/Shipping/Model/Source/Received.php +11 -0
  14. app/code/community/Shiphawk/Shipping/controllers/Adminhtml/ShipmentController.php +159 -0
  15. app/code/community/Shiphawk/Shipping/controllers/IndexController.php +98 -0
  16. app/code/community/Shiphawk/Shipping/etc/config.xml +130 -0
  17. app/code/community/Shiphawk/Shipping/etc/system.xml +227 -0
  18. app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-install-0.1.0.php +224 -0
  19. app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.0-0.7.1.php +9 -0
  20. app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.1-0.7.2.php +33 -0
  21. app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.2-1.0.0.php +19 -0
  22. app/design/adminhtml/default/default/layout/shiphawk.xml +25 -0
  23. app/etc/modules/Shiphawk_Shipping.xml +12 -0
  24. js/shiphawk/shiphawk.css +14 -0
  25. js/shiphawk/shiphawk.js +61 -0
  26. package.xml +22 -0
app/code/community/Shiphawk/Shipping/Block/Adminhtml/Sales/Order/Shipment/View.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Block_Adminhtml_Sales_Order_Shipment_View extends Mage_Adminhtml_Block_Sales_Order_Shipment_View {
3
+ public function __construct() {
4
+
5
+ parent::__construct();
6
+
7
+ if ($this->getShipment()->getId()) {
8
+ $this->_addButton('subscribe', array(
9
+ 'label' => Mage::helper('sales')->__('Subscribe to Tracking Information'),
10
+ 'class' => 'save',
11
+ 'onclick' => 'setLocation(\''.$this->getShipTrackUrl($this->getShipment()->getId()).'\')'
12
+ )
13
+ );
14
+ }
15
+ }
16
+
17
+ public function getShipTrackUrl($shipment_id) {
18
+ return Mage::helper("adminhtml")->getUrl("adminshiphawk/adminhtml_shipment/subscribe", array('shipment_id' => $shipment_id));
19
+ }
20
+ }
app/code/community/Shiphawk/Shipping/Block/Adminhtml/Sales/Order/View.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View {
3
+ public function __construct() {
4
+
5
+ parent::__construct();
6
+
7
+ $order_id = $this->getOrderId();
8
+ $order = $this->getOrder();
9
+
10
+ $manual_shipping = Mage::getStoreConfig('carriers/shiphawk_shipping/book_shipment');
11
+ $shipping_code = $order->getShippingMethod();
12
+
13
+ $confirm_messsage = $this->__('Are you sure to process?');
14
+ $check_shiphawk = Mage::helper('shiphawk_shipping')->isShipHawkShipping($shipping_code);
15
+ if($check_shiphawk !== false)
16
+ if ($order->canShip()) {
17
+ if($manual_shipping) {
18
+ $this->_addButton('shiphawk_shipping', array(
19
+ 'label' => Mage::helper('shiphawk_shipping')->__('ShipHawk Shipment'),
20
+ 'onclick' => "confirmSetLocation('{$confirm_messsage}', '{$this->getShipHawkUrl($order_id)}')",
21
+ 'class' => 'go'
22
+ ), 0, 100, 'header', 'header');
23
+ }
24
+ }
25
+
26
+ }
27
+
28
+ public function getShipHawkUrl($order_id) {
29
+ return Mage::helper("adminhtml")->getUrl("adminshiphawk/adminhtml_shipment/saveshipment", array('order_id' => $order_id));
30
+ }
31
+ }
app/code/community/Shiphawk/Shipping/Block/Catalog/Product/Helper/Form/Disabled.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Block_Catalog_Product_Helper_Form_Disabled extends Varien_Data_Form_Element_Text
3
+ {
4
+ public function getAfterElementHtml()
5
+ {
6
+ $html = parent::getAfterElementHtml();
7
+ return $html." <script>
8
+ $('".$this->getHtmlId()."').hide();
9
+ </script>";
10
+
11
+
12
+ }
13
+
14
+ }
app/code/community/Shiphawk/Shipping/Block/Catalog/Product/Helper/Form/Type.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Block_Catalog_Product_Helper_Form_Type extends Varien_Data_Form_Element_Text
3
+ {
4
+ public function getAfterElementHtml()
5
+ {
6
+ $html = parent::getAfterElementHtml();
7
+
8
+ $html .= '<style>
9
+ .type_link:hover {
10
+ text-decoration: underline;
11
+ cursor: pointer;
12
+ }
13
+ </style>';
14
+
15
+ $html .= '<div id="type_product" style="position: absolute; z-index: 99; background-color: #ffffff" ></div>';
16
+ return $html." <script>
17
+
18
+ var typeloader;
19
+ $('".$this->getHtmlId()."').observe('keyup', function(event){
20
+ clearTimeout(typeloader);
21
+ typeloader = setTimeout(function(){ respondToClick(event); }, 750);
22
+ });
23
+
24
+ function setIdValue(el) {
25
+
26
+ $('shiphawk_type_of_product').value = el.innerHTML;
27
+ $('shiphawk_type_of_product_value').value = el.id;
28
+ $('type_product').hide();
29
+ }
30
+
31
+ function respondToClick(event) {
32
+
33
+ var element = event.element();
34
+
35
+ var minlength = 3;
36
+
37
+ var url = '".$this->getTypeUrl()."';
38
+ var parameters = {
39
+ search_tag: element.value
40
+ };
41
+
42
+ if(element.value.length >= minlength ) {
43
+ new Ajax.Request(url, {
44
+ method: 'post',
45
+ parameters: parameters,
46
+ onSuccess: function(transport) {
47
+ $('type_product').update(transport.responseText);
48
+ $('type_product').show();
49
+ },
50
+ onLoading:function(transport)
51
+ {
52
+ }
53
+ });
54
+ }
55
+ }
56
+ </script>";
57
+
58
+ }
59
+
60
+ public function getTypeUrl() {
61
+ return Mage::getUrl('shiphawk/index/search');
62
+ }
63
+
64
+ }
app/code/community/Shiphawk/Shipping/Helper/Data.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Shiphawk_Shipping_Helper_Data extends
4
+ Mage_Core_Helper_Abstract
5
+ {
6
+ /**
7
+ * Get api key
8
+ *
9
+ * @return mixed
10
+ */
11
+ public function getApiKey()
12
+ {
13
+ return Mage::getStoreConfig('carriers/shiphawk_shipping/api_key');
14
+ }
15
+
16
+ /**
17
+ * Get callback url for shipments
18
+ *
19
+ * @return mixed
20
+ */
21
+ public function getCallbackUrl($api_key)
22
+ {
23
+ return Mage::getUrl('shiphawk/index/tracking', array('api_key' => $api_key));
24
+ }
25
+
26
+ public function getRateFilter()
27
+ {
28
+ return Mage::getStoreConfig('carriers/shiphawk_shipping/rate_filter');
29
+ }
30
+
31
+ /**
32
+ * Get api url
33
+ *
34
+ * @return mixed
35
+ */
36
+ public function getApiUrl()
37
+ {
38
+ //return 'https://sandbox.shiphawk.com/api/v1/';
39
+ return Mage::getStoreConfig('carriers/shiphawk_shipping/gateway_url');
40
+ }
41
+
42
+ /**
43
+ * Get Shiphawk attributes codes
44
+ *
45
+ * @return array
46
+ */
47
+ public function getAttributes()
48
+ {
49
+ $shiphawk_attributes = array('shiphawk_length','shiphawk_width', 'shiphawk_height', 'shiphawk_origin_zipcode', 'shiphawk_origin_firstname', 'shiphawk_origin_lastname'
50
+ ,'shiphawk_origin_addressline1','shiphawk_origin_phonenum','shiphawk_origin_city','shiphawk_origin_state','shiphawk_type_of_product','shiphawk_type_of_product_value'
51
+ ,'shiphawk_quantity', 'shiphawk_item_value','shiphawk_item_is_packed','shiphawk_origin_location');
52
+
53
+ return $shiphawk_attributes;
54
+ }
55
+
56
+ public function isShipHawkShipping($shipping_code) {
57
+ $result = strpos($shipping_code, 'shiphawk_shipping');
58
+ return $result;
59
+ }
60
+
61
+ public function getSipHawkCode($shiphawk_book_id, $shipping_description) {
62
+ $result = array();
63
+ foreach ($shiphawk_book_id as $rate_id=>$method_data) {
64
+ if( strpos($shipping_description, $method_data['name']) !== false ) {
65
+ $result = array($rate_id => $method_data);
66
+ return $result;
67
+ }
68
+ }
69
+ return null;
70
+ }
71
+
72
+
73
+ }
app/code/community/Shiphawk/Shipping/Model/Api.php ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Model_Api extends Mage_Core_Model_Abstract
3
+ {
4
+ public function getShiphawkRate($from_zip, $to_zip, $items, $rate_filter) {
5
+
6
+ $helper = Mage::helper('shiphawk_shipping');
7
+ $api_key = $helper->getApiKey();
8
+ $url_api_rates = $helper->getApiUrl() . 'rates/full?api_key=' . $api_key;
9
+
10
+ $from_type = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_location_type');
11
+ //$rate_filter = $helper->getRateFilter();
12
+ $curl = curl_init();
13
+
14
+ //TODO if products has various Origin Location Type ?
15
+ $items_array = array(
16
+ 'from_zip'=> $from_zip,
17
+ 'to_zip'=> $to_zip,
18
+ 'rate_filter' => $rate_filter,
19
+ 'items' => $items,
20
+ 'from_type' => $from_type
21
+ );
22
+
23
+ $items_array = json_encode($items_array);
24
+
25
+ curl_setopt($curl, CURLOPT_URL, $url_api_rates);
26
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
27
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $items_array);
28
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
29
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array(
30
+ 'Content-Type: application/json',
31
+ 'Content-Length: ' . strlen($items_array)
32
+ )
33
+ );
34
+
35
+ $resp = curl_exec($curl);
36
+
37
+ $arr_res = json_decode($resp);
38
+
39
+ curl_close($curl);
40
+ return $arr_res;
41
+ }
42
+
43
+ public function toBook($order,$rate_id)
44
+ {
45
+ $ship_addr = array();
46
+ $bill_addr = array();
47
+
48
+ if(is_object($order)) {
49
+ $ship_addr = $order->getShippingAddress()->getData();
50
+ $bill_addr = $order->getBillingAddress()->getData();
51
+ $order_increment_id = $order->getIncrementId();
52
+ }
53
+
54
+ $api_key = Mage::helper('shiphawk_shipping')->getApiKey();
55
+ $api_url = Mage::helper('shiphawk_shipping')->getApiUrl();
56
+ $url_api = $api_url . 'shipments/book?api_key=' . $api_key;
57
+
58
+ /* */
59
+ $origin_address_product = $this->_getProductOriginData($order);
60
+ /* */
61
+
62
+ $curl = curl_init();
63
+
64
+ $origin_address = $this->_getOriginData();
65
+
66
+ $next_bussines_day = date('Y-m-d', strtotime('now +1 Weekday'));
67
+ $items_array = array(
68
+ 'rate_id'=> $rate_id,
69
+ 'order_email'=> $ship_addr['email'],
70
+ 'xid'=>$order_increment_id,
71
+ 'origin_address' =>
72
+ array(
73
+ 'first_name' => $origin_address_product['origin_first_name'] ? $origin_address_product['origin_first_name'] : $origin_address['origin_first_name'],
74
+ 'last_name' => $origin_address_product['origin_last_name'] ? $origin_address_product['origin_last_name'] : $origin_address['origin_last_name'],
75
+ 'address_line_1' => $origin_address_product['origin_address'] ? $origin_address_product['origin_address'] : $origin_address['origin_address'],
76
+ 'address_line_2' => $origin_address_product['origin_address2'] ? $origin_address_product['origin_address2'] : $origin_address['origin_address2'],
77
+ 'phone_num' => $origin_address_product['origin_phone'] ? $origin_address_product['origin_phone'] : $origin_address['origin_phone'],
78
+ 'city' => $origin_address_product['origin_city'] ? $origin_address_product['origin_city'] : $origin_address['origin_city'],
79
+ 'state' => $origin_address_product['origin_state'] ? $origin_address_product['origin_state'] : $origin_address['origin_state'],
80
+ 'zipcode' => $origin_address_product['default_origin_zip'] ? $origin_address_product['default_origin_zip'] : $origin_address['default_origin_zip']
81
+ ),
82
+ 'destination_address' =>
83
+ array(
84
+ 'first_name' => $ship_addr['firstname'],
85
+ 'last_name' => $ship_addr['lastname'],
86
+ 'address_line_1' => $ship_addr['street'],
87
+ 'phone_num' => $ship_addr['telephone'],
88
+ 'city' => $ship_addr['city'],
89
+ 'state' => $ship_addr['region'],
90
+ 'zipcode' => $ship_addr['postcode']
91
+ ),
92
+ 'billing_address' =>
93
+ array(
94
+ 'first_name' => $bill_addr['firstname'],
95
+ 'last_name' => $bill_addr['lastname'],
96
+ 'address_line_1' => $bill_addr['street'],
97
+ 'phone_num' => $bill_addr['telephone'],
98
+ 'city' => $bill_addr['city'],
99
+ 'state' => $bill_addr['region'], //'NY',
100
+ 'zipcode' => $bill_addr['postcode']
101
+ ),
102
+ 'pickup' =>
103
+ array(
104
+ array(
105
+ 'start_time' => $next_bussines_day.'T04:00:00.645-07:00',
106
+ 'end_time' => $next_bussines_day.'T20:00:00.645-07:00',
107
+ ),
108
+ array(
109
+ 'start_time' => $next_bussines_day.'T04:00:00.645-07:00',
110
+ 'end_time' => $next_bussines_day.'T20:00:00.646-07:00',
111
+ )
112
+ ),
113
+
114
+ 'accessorials' => array()
115
+
116
+ );
117
+
118
+ $items_array = json_encode($items_array);
119
+
120
+ curl_setopt($curl, CURLOPT_URL, $url_api);
121
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
122
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $items_array);
123
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
124
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array(
125
+ 'Content-Type: application/json',
126
+ 'Content-Length: ' . strlen($items_array)
127
+ )
128
+ );
129
+
130
+ $resp = curl_exec($curl);
131
+ $arr_res = json_decode($resp);
132
+
133
+ curl_close($curl);
134
+
135
+ return $arr_res;
136
+
137
+ }
138
+
139
+ protected function _getOriginData() {
140
+ $origin_address = array();
141
+
142
+ $origin_address['origin_first_name'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_first_name');
143
+ $origin_address['origin_last_name'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_last_name');
144
+ $origin_address['origin_address'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_address');
145
+ $origin_address['origin_address2'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_address2');
146
+ $origin_address['origin_state'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_state');
147
+ $origin_address['origin_city'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_city');
148
+ $origin_address['default_origin_zip'] = Mage::getStoreConfig('carriers/shiphawk_shipping/default_origin');
149
+ $origin_address['origin_phone'] = Mage::getStoreConfig('carriers/shiphawk_shipping/origin_phone');
150
+
151
+ return $origin_address;
152
+ }
153
+
154
+ protected function _getProductOriginData($order) {
155
+ $origin_address_product = array();
156
+ try
157
+ {
158
+ $order_items = $order->getAllItems();
159
+ // get first product item
160
+ $origin_product = Mage::getModel('catalog/product')->load($order_items[0]->getProductId());
161
+
162
+ $origin_address_product['origin_first_name'] = $origin_product->getData('shiphawk_origin_firstname');
163
+ $origin_address_product['origin_last_name'] = $origin_product->getData('shiphawk_origin_lastname');
164
+ $origin_address_product['origin_address'] = $origin_product->getData('shiphawk_origin_addressline1');
165
+ $origin_address_product['origin_address2'] = $origin_product->getData('shiphawk_origin_addressline2');
166
+ $origin_address_product['origin_state'] = $origin_product->getData('shiphawk_origin_state');
167
+ $origin_address_product['origin_city'] = $origin_product->getData('shiphawk_origin_city');
168
+ $origin_address_product['default_origin_zip'] = $origin_product->getData('shiphawk_origin_zipcode');
169
+ $origin_address_product['origin_phone'] = $origin_product->getData('shiphawk_origin_phonenum');
170
+ }
171
+ catch(Exception $e)
172
+ {
173
+ Mage::log($e->getMessage());
174
+ }
175
+
176
+ return $origin_address_product;
177
+ }
178
+
179
+
180
+ /**
181
+ * Save shipment
182
+ * We can save only new shipment. Existing shipments are not editable
183
+ *
184
+ * @return null
185
+ */
186
+ public function saveshipment($orderId)
187
+ {
188
+ try {
189
+ $order = Mage::getModel('sales/order')->load($orderId);
190
+
191
+ $shiphawk_rate_data = unserialize($order->getData('shiphawk_book_id')); //rate id
192
+
193
+ foreach($shiphawk_rate_data as $rate_id=>$products_ids) {
194
+ $shipment = $this->_initShipHawkShipment($order,$products_ids);
195
+
196
+ $shipment->register();
197
+
198
+ $this->_saveShiphawkShipment($shipment);
199
+
200
+ // add book
201
+
202
+ $track_data = $this->toBook($order,$rate_id);
203
+
204
+ // add track
205
+ if($track_number = $track_data->shipment_id) {
206
+ $this->addTrackNumber($shipment, $track_number);
207
+ }
208
+ }
209
+
210
+ } catch (Mage_Core_Exception $e) {
211
+
212
+ Mage::logException($e);
213
+
214
+ } catch (Exception $e) {
215
+ Mage::logException($e);
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Initialize shipment model instance
221
+ *
222
+ * @return Mage_Sales_Model_Order_Shipment|bool
223
+ */
224
+ public function _initShipHawkShipment($order, $products_ids)
225
+ {
226
+ $shipment = false;
227
+ if(is_object($order)) {
228
+
229
+ $savedQtys = $this->_getItems($order, $products_ids);
230
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($savedQtys);
231
+ }
232
+
233
+ return $shipment;
234
+ }
235
+
236
+ public function _getItems($order, $products_ids) {
237
+ $qty = array();
238
+ if(is_object($order)) {
239
+ foreach($order->getAllItems() as $eachOrderItem){
240
+
241
+ if(in_array($eachOrderItem->getProductId(),$products_ids['product_ids'])) {
242
+ $Itemqty = 0;
243
+ $Itemqty = $eachOrderItem->getQtyOrdered()
244
+ - $eachOrderItem->getQtyShipped()
245
+ - $eachOrderItem->getQtyRefunded()
246
+ - $eachOrderItem->getQtyCanceled();
247
+ $qty[$eachOrderItem->getId()] = $Itemqty;
248
+ }else{
249
+ $qty[$eachOrderItem->getId()] = 0;
250
+ }
251
+
252
+ }
253
+ }
254
+
255
+ return $qty;
256
+ }
257
+
258
+ /**
259
+ * Save shipment and order in one transaction
260
+ *
261
+ * @param Mage_Sales_Model_Order_Shipment $shipment
262
+ * @return Mage_Adminhtml_Sales_Order_ShipmentController
263
+ */
264
+ public function _saveShiphawkShipment($shipment)
265
+ {
266
+ $shipment->getOrder()->setIsInProcess(true);
267
+ $transactionSave = Mage::getModel('core/resource_transaction')
268
+ ->addObject($shipment)
269
+ ->addObject($shipment->getOrder())
270
+ ->save();
271
+
272
+ return $this;
273
+ }
274
+
275
+ /**
276
+ * Add new tracking number action
277
+ */
278
+ public function addTrackNumber($shipment, $number)
279
+ {
280
+ try {
281
+ $carrier = 'shiphawk_shipping';
282
+
283
+ $title = 'ShipHawk Shipping';
284
+ if (empty($carrier)) {
285
+ Mage::throwException($this->__('The carrier needs to be specified.'));
286
+ }
287
+ if (empty($number)) {
288
+ Mage::throwException($this->__('Tracking number cannot be empty.'));
289
+ }
290
+
291
+ if ($shipment) {
292
+ $track = Mage::getModel('sales/order_shipment_track')
293
+ ->setNumber($number)
294
+ ->setCarrierCode($carrier)
295
+ ->setTitle($title);
296
+ $shipment->addTrack($track)
297
+ ->save();
298
+
299
+ } else {
300
+ Mage::log('Cannot initialize shipment for adding tracking number.');
301
+ }
302
+ } catch (Mage_Core_Exception $e) {
303
+ Mage::log($e->getMessage());
304
+ } catch (Exception $e) {
305
+ Mage::log('Cannot add tracking number.');
306
+ }
307
+
308
+ }
309
+
310
+ }
app/code/community/Shiphawk/Shipping/Model/Carrier.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Shiphawk_Shipping_Model_Carrier
4
+ extends Mage_Shipping_Model_Carrier_Abstract
5
+ implements Mage_Shipping_Model_Carrier_Interface
6
+ {
7
+ /**
8
+ * Carrier's code, as defined in parent class
9
+ *
10
+ * @var string
11
+ */
12
+ protected $_code = 'shiphawk_shipping';
13
+
14
+ /**
15
+ * Returns available shipping rates for Shiphawk Shipping carrier
16
+ *
17
+ * @param Mage_Shipping_Model_Rate_Request $request
18
+ * @return Mage_Shipping_Model_Rate_Result
19
+ */
20
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
21
+ {
22
+ /** @var Mage_Shipping_Model_Rate_Result $result */
23
+ $result = Mage::getModel('shipping/rate_result');
24
+
25
+ $helper = Mage::helper('shiphawk_shipping');
26
+ $default_origin_zip = Mage::getStoreConfig('carriers/shiphawk_shipping/default_origin');
27
+
28
+ $to_zip = $this->getShippingZip();
29
+ $api = Mage::getModel('shiphawk_shipping/api');
30
+ $items = $this->getShiphawkItems($request);
31
+
32
+ $grouped_items_by_zip = $this->getGroupedItemsByZip($items);
33
+
34
+ $ship_responces = array();
35
+ $toOrder= array();
36
+ $api_error = false;
37
+ $is_multi_zip = (count($grouped_items_by_zip) > 1) ? true : false;
38
+ $rate_filter = Mage::helper('shiphawk_shipping')->getRateFilter();
39
+ if($is_multi_zip) {
40
+ $rate_filter = 'best';
41
+ }
42
+ try {
43
+ foreach($grouped_items_by_zip as $from_zip=>$items_) {
44
+ $responceObject = $api->getShiphawkRate($from_zip, $to_zip, $items_, $rate_filter);
45
+ $ship_responces[] = $responceObject;
46
+
47
+ //TODO Notice : Trying to get property of non-object ( if !is_array,
48
+ if(is_object($responceObject)) {
49
+ $api_error = true;
50
+ Mage::log('ShipHawk responce: '.$responceObject->error, null, 'ShipHawk.log');
51
+ }else{
52
+ // if $rate_filter = 'best' then it is only one rate
53
+ if(($is_multi_zip)||($rate_filter == 'best')) {
54
+ Mage::getSingleton('core/session')->setMultiZipCode(true);
55
+ $toOrder[$responceObject[0]->id]['product_ids'] = $this->_getProductIds($items_);
56
+ $toOrder[$responceObject[0]->id]['price'] = $responceObject[0]->price;
57
+ $toOrder[$responceObject[0]->id]['name'] = $responceObject[0]->service;
58
+ $toOrder[$responceObject[0]->id]['items'] = $items_;
59
+ $toOrder[$responceObject[0]->id]['from_zip'] = $from_zip;
60
+ $toOrder[$responceObject[0]->id]['to_zip'] = $to_zip;
61
+ }else{
62
+ Mage::getSingleton('core/session')->setMultiZipCode(false);
63
+ foreach ($responceObject as $responce) {
64
+ $toOrder[$responce->id]['product_ids'] = $this->_getProductIds($items_);
65
+ $toOrder[$responce->id]['price'] = $responce->price;
66
+ $toOrder[$responce->id]['name'] = $responce->service;
67
+ $toOrder[$responce->id]['items'] = $items_;
68
+ $toOrder[$responce->id]['from_zip'] = $from_zip;
69
+ $toOrder[$responce->id]['to_zip'] = $to_zip;
70
+ }
71
+ }
72
+ }
73
+
74
+ /* if((!$responceObject->error)) {
75
+ // if $rate_filter = 'best' then it is only one rate
76
+ if(($is_multi_zip)||($rate_filter == 'best')) {
77
+ Mage::getSingleton('core/session')->setMultiZipCode(true);
78
+ $toOrder[$responceObject[0]->id]['product_ids'] = $this->_getProductIds($items_);
79
+ $toOrder[$responceObject[0]->id]['price'] = $responceObject[0]->price;
80
+ $toOrder[$responceObject[0]->id]['name'] = $responceObject[0]->service;
81
+ $toOrder[$responceObject[0]->id]['items'] = $items_;
82
+ $toOrder[$responceObject[0]->id]['from_zip'] = $from_zip;
83
+ $toOrder[$responceObject[0]->id]['to_zip'] = $to_zip;
84
+ }else{
85
+ Mage::getSingleton('core/session')->setMultiZipCode(false);
86
+ foreach ($responceObject as $responce) {
87
+ $toOrder[$responce->id]['product_ids'] = $this->_getProductIds($items_);
88
+ $toOrder[$responce->id]['price'] = $responce->price;
89
+ $toOrder[$responce->id]['name'] = $responce->service;
90
+ $toOrder[$responce->id]['items'] = $items_;
91
+ $toOrder[$responce->id]['from_zip'] = $from_zip;
92
+ $toOrder[$responce->id]['to_zip'] = $to_zip;
93
+ }
94
+ }
95
+ }else{
96
+ $api_error = true;
97
+ Mage::log('ShipHawk responce: '.$responceObject->error, null, 'ShipHawk.log');
98
+ }*/
99
+
100
+ }
101
+
102
+ if(!$api_error) {
103
+ $services = $this->_getServices($ship_responces);
104
+ $name_service = '';
105
+ $summ_price = 0;
106
+
107
+ foreach ($services as $id_service=>$service) {
108
+ if (!$is_multi_zip) {
109
+ //add ShipHawk shipping
110
+ $result->append($this->_getShiphawkRateObject($service['name'], $service['price']));
111
+ }else{
112
+ $name_service .= $service['name'] . ', ';
113
+ $summ_price += $service['price'];
114
+ }
115
+ }
116
+
117
+ //save rate_id info for Book
118
+ Mage::getSingleton('core/session')->setShiphawkBookId($toOrder);
119
+
120
+ //remove last comma
121
+ if(strlen($name_service) >2) {
122
+ if ($name_service{strlen($name_service)-2} == ',') {
123
+ $name_service = substr($name_service,0,-2);
124
+ }
125
+ }
126
+
127
+ if($is_multi_zip) {
128
+ //add ShipHawk shipping
129
+ $result->append($this->_getShiphawkRateObject($name_service, $summ_price));
130
+ }
131
+ }
132
+
133
+ }catch (Mage_Core_Exception $e) {
134
+ Mage::logException($e->getMessage());
135
+ } catch (Exception $e) {
136
+ Mage::logException($e->getMessage());
137
+ }
138
+ return $result;
139
+ }
140
+
141
+ /**
142
+ * Returns Allowed shipping methods
143
+ *
144
+ * @return array
145
+ */
146
+ public function getAllowedMethods()
147
+ {
148
+ return array(
149
+ 'ground' => 'Ground delivery',
150
+ );
151
+ }
152
+
153
+ protected function _getProductIds($_items) {
154
+ $products_ids = array();
155
+ foreach($_items as $_item) {
156
+ $products_ids[] = $_item['product_id'];
157
+ }
158
+ return $products_ids;
159
+ }
160
+
161
+ /**
162
+ * Get Standard rate object
163
+ *
164
+ * @return Mage_Shipping_Model_Rate_Result_Method
165
+ */
166
+ protected function _getShiphawkRateObject($method_title, $price)
167
+ {
168
+ /** @var Mage_Shipping_Model_Rate_Result_Method $rate */
169
+ $rate = Mage::getModel('shipping/rate_result_method');
170
+
171
+ $rate->setCarrier($this->_code);
172
+ //$rate->setCarrierTitle($this->getConfigData('title'));
173
+ $rate->setCarrierTitle('ShipHawk');
174
+ $rate->setMethodTitle($method_title);
175
+ $rate->setMethod(str_replace(',', '', str_replace(' ', '_', $method_title)));
176
+ $rate->setPrice($price);
177
+ $rate->setCost($price);
178
+
179
+ return $rate;
180
+ }
181
+
182
+ public function getShiphawkItems($request) {
183
+ $items = array();
184
+
185
+ foreach ($request->getAllItems() as $item) {
186
+ $product_id = $item->getProductId();
187
+ $product = Mage::getModel('catalog/product')->load($product_id);
188
+ if($product->getWeight() > 0) {
189
+ $items[] = array(
190
+ 'width' => $product->getShiphawkWidth(),
191
+ 'length' => $product->getShiphawkLength(),
192
+ 'height' => $product->getShiphawkHeight(),
193
+ 'weight' => $product->getWeight(),
194
+ 'value' => $this->getShipHawkItemValue($product),
195
+ 'quantity' => $product->getShiphawkQuantity()*$item->getQty(),
196
+ 'is_packed' => $this->getIsPacked($product),
197
+ 'id' => $product->getShiphawkTypeOfProductValue(),
198
+ 'zip'=> $this->getOriginZip($product),
199
+ 'product_id'=> $product_id
200
+ );
201
+ }else{
202
+ $items[] = array(
203
+ 'width' => $product->getShiphawkWidth(),
204
+ 'length' => $product->getShiphawkLength(),
205
+ 'height' => $product->getShiphawkHeight(),
206
+ 'value' => $this->getShipHawkItemValue($product),
207
+ 'quantity' => $product->getShiphawkQuantity()*$item->getQty(),
208
+ 'is_packed' => $this->getIsPacked($product),
209
+ 'id' => $product->getShiphawkTypeOfProductValue(),
210
+ 'zip'=> $this->getOriginZip($product),
211
+ 'product_id'=> $product_id
212
+ );
213
+ }
214
+
215
+ }
216
+
217
+ return $items;
218
+ }
219
+
220
+ public function getShippingZip() {
221
+ if (Mage::app()->getStore()->isAdmin()) {
222
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
223
+ }else{
224
+ /** @var $cart Mage_Checkout_Model_Cart */
225
+ $cart = Mage::getSingleton('checkout/cart');
226
+ $quote = $cart->getQuote();
227
+ }
228
+
229
+ $shippingAddress = $quote->getShippingAddress();
230
+ $zip_code = $shippingAddress->getPostcode();
231
+ return $zip_code;
232
+ }
233
+
234
+ public function getShipHawkItemValue($product) {
235
+ if($product->getShiphawkQuantity() > 0) {
236
+ $product_price = $product->getPrice()/$product->getShiphawkQuantity();
237
+ }else{
238
+ $product_price = $product->getPrice();
239
+ }
240
+ $item_value = ($product->getShiphawkItemValue() > 0) ? $product->getShiphawkItemValue() : $product_price;
241
+ return $item_value;
242
+ }
243
+
244
+ public function getOriginZip($product) {
245
+ $default_origin_zip = Mage::getStoreConfig('carriers/shiphawk_shipping/default_origin');
246
+ $product_origin_zip_code = $product->getShiphawkOriginZipcode();
247
+ $product_origin_zip_code = (empty($product_origin_zip_code)) ? $default_origin_zip : $product_origin_zip_code;
248
+
249
+ return $product_origin_zip_code;
250
+ }
251
+
252
+ public function getIsPacked($product) {
253
+ $default_is_packed = Mage::getStoreConfig('carriers/shiphawk_shipping/item_is_packed');
254
+ $product_is_packed = $product->getShiphawkItemIsPacked();
255
+ $product_is_packed = ($product_is_packed == 2) ? $default_is_packed : $product_is_packed;
256
+
257
+ return $product_is_packed;
258
+ }
259
+
260
+ public function getGroupedItemsByZip($items) {
261
+ $tmp = array();
262
+ foreach($items as $item) {
263
+ $tmp[$item['zip']][] = $item;
264
+ }
265
+ return $tmp;
266
+ }
267
+
268
+ protected function _getServices($ship_responces) {
269
+ $services = array();
270
+ foreach($ship_responces as $ship_responce) {
271
+ if(is_array($ship_responce)) {
272
+ foreach($ship_responce as $object) {
273
+ $services[$object->id]['name'] = $object->service;
274
+ $services[$object->id]['price'] = $object->price;
275
+ }
276
+ }
277
+ }
278
+
279
+ return $services;
280
+ }
281
+
282
+
283
+ }
app/code/community/Shiphawk/Shipping/Model/Observer.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Model_Observer extends Mage_Core_Model_Abstract
3
+ {
4
+ public function configSaveAfter($observer){
5
+
6
+ /*$is_requered_attr = Mage::getStoreConfig('carriers/shiphawk_shipping/required_attribute');
7
+ $shiphawk_attributes = Mage::helper('shiphawk_shipping')->getAttributes();
8
+
9
+ foreach($shiphawk_attributes as $attributeCode) {
10
+ $this->_setAttributeRequired($attributeCode,$is_requered_attr);
11
+ }*/
12
+
13
+ }
14
+
15
+ protected function _setAttributeRequired($attributeCode, $is_active) {
16
+ $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode( 'catalog_product', $attributeCode);
17
+ $attributeModel->setIsRequired($is_active);
18
+ $attributeModel->save();
19
+ }
20
+
21
+ public function salesOrderPlaceAfter($observer) {
22
+ $event = $observer->getEvent();
23
+ $order = $event->getOrder();
24
+ $orderId = $order->getId();
25
+
26
+ $helper = Mage::helper('shiphawk_shipping');
27
+
28
+ $manual_shipping = Mage::getStoreConfig('carriers/shiphawk_shipping/book_shipment');
29
+ $shipping_code = $order->getShippingMethod();
30
+ $shipping_description = $order->getShippingDescription();
31
+ $check_shiphawk = Mage::helper('shiphawk_shipping')->isShipHawkShipping($shipping_code);
32
+ if($check_shiphawk !== false) {
33
+ /* set ShipHawk rate */
34
+ $shiphawk_book_id = Mage::getSingleton('core/session')->getShiphawkBookId();
35
+
36
+ $multi_zip_code = Mage::getSingleton('core/session')->getMultiZipCode();
37
+
38
+ if($multi_zip_code == false) {
39
+ $shiphawk_book_id = $helper->getSipHawkCode($shiphawk_book_id, $shipping_description);
40
+ }
41
+
42
+ $order->setShiphawkBookId(serialize($shiphawk_book_id));
43
+ $order->save();
44
+ if(!$manual_shipping) {
45
+ if ($order->canShip()) {
46
+ $api = Mage::getModel('shiphawk_shipping/api');
47
+ $api->saveshipment($orderId);
48
+ }
49
+ }
50
+ }
51
+
52
+ Mage::getSingleton('core/session')->unsShiphawkBookId();
53
+ Mage::getSingleton('core/session')->unsMultiZipCode();
54
+
55
+ }
56
+
57
+ public function saveShipHawkId() {
58
+ //do not enter in this event
59
+
60
+ /*$ship_hawk_id = Mage::getSingleton('core/session')->getShiphawkId();
61
+ $order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
62
+
63
+ $order->setShiphawkApiId($ship_hawk_id);
64
+ $order->save();
65
+
66
+
67
+
68
+ Mage::getSingleton('core/session')->unsShiphawkId();*/
69
+ }
70
+
71
+ //lock attributes by code
72
+ /*public function lockAttributes($observer) {
73
+ $event = $observer->getEvent();
74
+ $product = $event->getProduct();
75
+ $product->lockAttribute('shiphawk_type_of_product_value');
76
+ $product->lockAttribute('shiphawk_product_id');
77
+ }*/
78
+ }
app/code/community/Shiphawk/Shipping/Model/Product/Attribute/Source/Location.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Model_Product_Attribute_Source_Location
3
+ extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
4
+ {
5
+ /**
6
+ * Retrieve all attribute options
7
+ *
8
+ * @return array
9
+ */
10
+ public function getAllOptions()
11
+ {
12
+ $this->_options = array(
13
+ array(
14
+ 'label' => Mage::helper('catalog')->__('commercial'),
15
+ 'value' => Mage::helper('catalog')->__('commercial')
16
+ ),
17
+ array(
18
+ 'label' => Mage::helper('catalog')->__('residential'),
19
+ 'value' => Mage::helper('catalog')->__('residential')
20
+ )
21
+ );
22
+
23
+ return $this->_options;
24
+ }
25
+ }
app/code/community/Shiphawk/Shipping/Model/Source/Gateway.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Model_Source_Gateway
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'https://shiphawk.com/api/v1/', 'label'=>Mage::helper('adminhtml')->__('Live')),
8
+ array('value'=>'https://sandbox.shiphawk.com/api/v1/', 'label'=>Mage::helper('adminhtml')->__('Sandbox')),
9
+ );
10
+ }
11
+ }
app/code/community/Shiphawk/Shipping/Model/Source/Location.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Model_Source_Location
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'commercial', 'label'=>Mage::helper('adminhtml')->__('commercial')),
8
+ array('value'=>'residential', 'label'=>Mage::helper('adminhtml')->__('residential')),
9
+ );
10
+ }
11
+ }
app/code/community/Shiphawk/Shipping/Model/Source/Ratefilter.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Model_Source_Ratefilter
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>'consumer', 'label'=>Mage::helper('adminhtml')->__('consumer')),
8
+ array('value'=>'best', 'label'=>Mage::helper('adminhtml')->__('best')),
9
+ );
10
+ }
11
+ }
app/code/community/Shiphawk/Shipping/Model/Source/Received.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Model_Source_Received
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>0, 'label'=>Mage::helper('adminhtml')->__('customer')),
8
+ array('value'=>1, 'label'=>Mage::helper('adminhtml')->__('administrator')),
9
+ );
10
+ }
11
+ }
app/code/community/Shiphawk/Shipping/controllers/Adminhtml/ShipmentController.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ public function subscribeAction() {
5
+ $shipment_id = $this->getRequest()->getParam('shipment_id');
6
+
7
+ $helper = Mage::helper('shiphawk_shipping');
8
+ $api_key = $helper->getApiKey();
9
+
10
+
11
+ if($shipment_id) {
12
+ try{
13
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipment_id);
14
+
15
+ $shipment_id_track = $this->_getTrackNumber($shipment);
16
+
17
+ $subscribe_url = $helper->getApiUrl() . 'shipments/' . $shipment_id_track . '/subscribe?api_key=' . $api_key;
18
+ $callback_url = $helper->getCallbackUrl($api_key);
19
+
20
+ $items_array = array(
21
+ 'callback_url'=> $callback_url
22
+ );
23
+
24
+ $curl = curl_init();
25
+ $items_array = json_encode($items_array);
26
+
27
+ curl_setopt($curl, CURLOPT_URL, $subscribe_url);
28
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
29
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $items_array);
30
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
31
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array(
32
+ 'Content-Type: application/json',
33
+ 'Content-Length: ' . strlen($items_array)
34
+ )
35
+ );
36
+
37
+ $resp = curl_exec($curl);
38
+ $arr_res = json_decode($resp);
39
+
40
+ if (!empty($arr_res)) {
41
+ $shipment->addComment($resp);
42
+ }
43
+
44
+ $shipment->save();
45
+
46
+ curl_close($curl);
47
+
48
+ }catch (Mage_Core_Exception $e) {
49
+ $this->_getSession()->addError($e->getMessage());
50
+
51
+ } catch (Exception $e) {
52
+ Mage::logException($e);
53
+ $this->_getSession()->addError($this->__('Cannot load shipment.'));
54
+ }
55
+
56
+ }else{
57
+ $this->_getSession()->addWarning($this->__('No ShipHawk tracking number'));
58
+ }
59
+
60
+ //$this->_getSession()->addSuccess($this->__('Subscribe'));
61
+ $this->_redirect('adminhtml/sales_shipment/view', array('shipment_id' => $shipment_id));
62
+ }
63
+
64
+ protected function _getTrackNumber($shipment) {
65
+
66
+ foreach($shipment->getAllTracks() as $tracknum)
67
+ {
68
+ //ShipHawk track number only one
69
+ if($tracknum->getCarrierCode() == 'shiphawk_shipping') {
70
+ return $tracknum->getNumber();
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+
76
+ /**
77
+ * Save shipment
78
+ * We can save only new shipment. Existing shipments are not editable
79
+ *
80
+ * @return null
81
+ */
82
+ public function saveshipmentAction()
83
+ {
84
+ $orderId= $this->getRequest()->getParam('order_id');
85
+
86
+ try {
87
+ $order = Mage::getModel('sales/order')->load($orderId);
88
+
89
+ $shiphawk_rate_data = unserialize($order->getData('shiphawk_book_id')); //rate id
90
+
91
+ $api = Mage::getModel('shiphawk_shipping/api');
92
+
93
+ $items = Mage::getModel('shiphawk_shipping/carrier')->getShiphawkItems($order);
94
+
95
+ $grouped_items_by_zip = Mage::getModel('shiphawk_shipping/carrier')->getGroupedItemsByZip($items);
96
+
97
+ $shipping_description = $order->getShippingDescription();
98
+
99
+ $is_multi_zip = (count($grouped_items_by_zip) > 1) ? true : false;
100
+ $rate_filter = Mage::helper('shiphawk_shipping')->getRateFilter();
101
+ if($is_multi_zip) {
102
+ $rate_filter = 'best';
103
+ }
104
+
105
+ foreach($shiphawk_rate_data as $rate_id=>$products_ids) {
106
+ $is_rate = false;
107
+ //если $is_multi_zip то используем $rate_filter = best значит в респонсе будет всего один метод
108
+ if(($is_multi_zip)||($rate_filter == 'best')) {
109
+ $responceObject = $api->getShiphawkRate($products_ids['from_zip'], $products_ids['to_zip'], $products_ids['items'], $rate_filter);
110
+ // get only one method for each group of product
111
+ $rate_id = $responceObject[0]->id;
112
+ $is_rate = true;
113
+ }else{
114
+ $responceObject = $api->getShiphawkRate($products_ids['from_zip'], $products_ids['to_zip'], $products_ids['items'], $rate_filter);
115
+
116
+ foreach ($responceObject as $responce) {
117
+ if( strpos($shipping_description, $responce->service) !== false ) {
118
+ $rate_id = $responce->id;
119
+ $is_rate = true;
120
+ break;
121
+ }
122
+ }
123
+ }
124
+
125
+ if($is_rate == true) {
126
+ // add book
127
+ $track_data = $api->toBook($order,$rate_id);
128
+
129
+ $shipment = $api->_initShipHawkShipment($order,$products_ids);
130
+ $shipment->register();
131
+ $api->_saveShiphawkShipment($shipment);
132
+
133
+ // add track
134
+ if($track_number = $track_data->shipment_id) {
135
+ $api->addTrackNumber($shipment, $track_number);
136
+ }
137
+
138
+ $shipmentCreatedMessage = $this->__('The shipment has been created.');
139
+ $this->_getSession()->addSuccess($shipmentCreatedMessage);
140
+ }else{
141
+ Mage::getSingleton('core/session')->addError("Unfortunately the method that was chosen by a customer during checkout is currently unavailable. Please contact ShipHawk's customer service to manually book this shipment.");
142
+ }
143
+
144
+ }
145
+
146
+
147
+ } catch (Mage_Core_Exception $e) {
148
+ $this->_getSession()->addError($e->getMessage());
149
+ $this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
150
+ } catch (Exception $e) {
151
+ Mage::logException($e);
152
+ $this->_getSession()->addError($this->__('Cannot save shipment.'));
153
+ $this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
154
+ }
155
+
156
+ $this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
157
+ }
158
+
159
+ }
app/code/community/Shiphawk/Shipping/controllers/IndexController.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Shiphawk_Shipping_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function trackingAction() {
5
+
6
+ // var_dump (file_get_contents('php://input'));
7
+ $api_key_from_url = $this->getRequest()->getParam('api_key');
8
+ $data_from_shiphawk = json_decode(file_get_contents('php://input'));
9
+ $api_key = Mage::helper('shiphawk_shipping')->getApiKey();
10
+
11
+ //curl -X POST -H Content-Type:application/json -d '{"event":"shipment.status_update","status":"in_transit","updated_at":"2015-01-14T10:43:16.702-08:00","shipment_id":1010226}' http://shiphawk.devigor.wdgtest.com/index.php/shiphawk/index/tracking?api_key=3331b35952ec7d99338a1cc5c496b55c
12
+
13
+ if($api_key_from_url == $api_key) {
14
+ try {
15
+ $track_number = $data_from_shiphawk->shipment_id;
16
+ $shipment_track = Mage::getResourceModel('sales/order_shipment_track_collection')->addAttributeToFilter('track_number', $track_number)->getFirstItem();
17
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipment_track->getParentId());
18
+
19
+ $data_from_shiphawk = (array) $data_from_shiphawk;
20
+
21
+ $shipment_status_updates = Mage::getStoreConfig('carriers/shiphawk_shipping/shipment_status_updates');
22
+ $updates_tracking_url = Mage::getStoreConfig('carriers/shiphawk_shipping/updates_tracking_url');
23
+ $comment = '';
24
+
25
+ if($data_from_shiphawk['event'] == 'shipment.status_update') {
26
+ $comment = $data_from_shiphawk['updated_at'] . ': Status has been changed to ' . $data_from_shiphawk['status'];
27
+ $shipment->addComment($comment);
28
+ if($shipment_status_updates) {
29
+ $shipment->sendUpdateEmail(true, $comment);
30
+ }
31
+ }
32
+
33
+ if($data_from_shiphawk['event'] == 'shipment.tracking_update') {
34
+ $comment = $data_from_shiphawk['updated_at'] . 'There is a tracking number available for your shipment - ' . $data_from_shiphawk['tracking_number'] . '<a href="' . $data_from_shiphawk['tracking_url'] . '" target="_blank">Click here to track.</a>';
35
+ $shipment->addComment($comment);
36
+ if($updates_tracking_url) {
37
+ $shipment->sendUpdateEmail(true, $comment);
38
+ }
39
+ }
40
+
41
+ //$shipment->addComment(implode(',', $data_from_shiphawk));
42
+
43
+ $shipment->save();
44
+ }catch (Mage_Core_Exception $e) {
45
+ Mage::logException($e->getMessage());
46
+ } catch (Exception $e) {
47
+ Mage::logException($e->getMessage());
48
+ }
49
+
50
+ }
51
+ }
52
+
53
+ /* suggest items type in product page */
54
+ public function searchAction() {
55
+
56
+ $search_tag = trim(strip_tags($this->getRequest()->getPost('search_tag')));
57
+
58
+ $api_key = Mage::helper('shiphawk_shipping')->getApiKey();
59
+ $api_url = Mage::helper('shiphawk_shipping')->getApiUrl();
60
+
61
+ $url_api = $api_url . 'items/search/'.$search_tag.'?api_key='.$api_key;
62
+ $curl = curl_init();
63
+
64
+ curl_setopt_array($curl, array(
65
+ CURLOPT_RETURNTRANSFER => true,
66
+ CURLOPT_URL => $url_api,
67
+ CURLOPT_POST => false
68
+ ));
69
+
70
+ $resp = curl_exec($curl);
71
+ $arr_res = json_decode($resp);
72
+ $responce_array = array();
73
+ $responce = array();
74
+
75
+ if(($arr_res->error) || ($arr_res['error'])) {
76
+
77
+ Mage::log($arr_res->error, null, 'ShipHawk.log');
78
+ $responce_html = '';
79
+ $responce['shiphawk_error'] = $arr_res->error;
80
+ }else{
81
+ foreach ((array) $arr_res as $el) {
82
+ $responce_array[$el->id] = $el->name.' ('.$el->category.')';
83
+ }
84
+
85
+ $responce_html="<ul>";
86
+
87
+ foreach($responce_array as $key=>$value) {
88
+ $responce_html .='<li class="type_link" id='.$key.' onclick="setItemid(this)" >'.$value.'</li>';
89
+ }
90
+
91
+ $responce_html .="</ul>";
92
+ }
93
+ $responce['responce_html'] = $responce_html;
94
+ curl_close($curl);
95
+
96
+ $this->getResponse()->setBody( json_encode($responce) );
97
+ }
98
+ }
app/code/community/Shiphawk/Shipping/etc/config.xml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Shiphawk_Shipping>
5
+ <version>1.0.0</version>
6
+ </Shiphawk_Shipping>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <shiphawk_shipping>
11
+ <class>Shiphawk_Shipping_Model</class>
12
+ </shiphawk_shipping>
13
+ </models>
14
+ <blocks>
15
+ <shiphawk_shipping>
16
+ <class>Shiphawk_Shipping_Block</class>
17
+ </shiphawk_shipping>
18
+ <adminhtml>
19
+ <rewrite>
20
+ <sales_order_view>Shiphawk_Shipping_Block_Adminhtml_Sales_Order_View</sales_order_view>
21
+ <sales_order_shipment_view>Shiphawk_Shipping_Block_Adminhtml_Sales_Order_Shipment_View</sales_order_shipment_view>
22
+ </rewrite>
23
+ </adminhtml>
24
+ </blocks>
25
+ <resources>
26
+ <shiphawk_setup>
27
+ <setup>
28
+ <module>Shiphawk_Shipping</module>
29
+ </setup>
30
+ <connection>
31
+ <use>core_setup</use>
32
+ </connection>
33
+ </shiphawk_setup>
34
+ </resources>
35
+ <helpers>
36
+ <shiphawk_shipping>
37
+ <class>Shiphawk_Shipping_Helper</class>
38
+ </shiphawk_shipping>
39
+ </helpers>
40
+ <events>
41
+ <admin_system_config_changed_section_carriers>
42
+ <observers>
43
+ <shiphawk_shipping_config_save>
44
+ <type>singleton</type>
45
+ <class>shiphawk_shipping/observer</class>
46
+ <method>configSaveAfter</method>
47
+ </shiphawk_shipping_config_save>
48
+ </observers>
49
+ </admin_system_config_changed_section_carriers>
50
+ <sales_order_place_after>
51
+ <observers>
52
+ <shiphawk_shipping_order_place>
53
+ <type>singleton</type>
54
+ <class>shiphawk_shipping/observer</class>
55
+ <method>salesOrderPlaceAfter</method>
56
+ </shiphawk_shipping_order_place>
57
+ </observers>
58
+ </sales_order_place_after>
59
+ </events>
60
+ <fieldsets>
61
+ <sales_convert_quote>
62
+ <shiphawk_api_id>
63
+ <to_order>*</to_order>
64
+ </shiphawk_api_id>
65
+ </sales_convert_quote>
66
+ <sales_convert_quote_item>
67
+ <shiphawk_api_id>
68
+ <to_order_item>*</to_order_item>
69
+ </shiphawk_api_id>
70
+ </sales_convert_quote_item>
71
+ </fieldsets>
72
+ </global>
73
+ <frontend>
74
+ <routers>
75
+ <Shiphawk_Shipping>
76
+ <use>standard</use>
77
+ <args>
78
+ <module>Shiphawk_Shipping</module>
79
+ <frontName>shiphawk</frontName>
80
+ </args>
81
+ </Shiphawk_Shipping>
82
+ </routers>
83
+ </frontend>
84
+ <adminhtml>
85
+ <layout>
86
+ <updates>
87
+ <shiphawk_shipping>
88
+ <file>shiphawk.xml</file>
89
+ </shiphawk_shipping>
90
+ </updates>
91
+ </layout>
92
+ </adminhtml>
93
+ <!--<admin>
94
+ <routers>
95
+ <adminhtml>
96
+ <args>
97
+ <modules>
98
+ <shiphawk_shipping before="Mage_Adminhtml">Shiphawk_Shipping_Adminhtml</shiphawk_shipping>
99
+ </modules>
100
+ </args>
101
+ </adminhtml>
102
+ </routers>
103
+ </admin>-->
104
+ <admin>
105
+ <routers>
106
+ <shiphawk_shipping>
107
+ <use>admin</use>
108
+ <args>
109
+ <module>Shiphawk_Shipping</module>
110
+ <frontName>adminshiphawk</frontName>
111
+ </args>
112
+ </shiphawk_shipping>
113
+ </routers>
114
+ </admin>
115
+ <default>
116
+ <carriers>
117
+ <shiphawk_shipping>
118
+ <active>1</active>
119
+ <updates_tracking_url>0</updates_tracking_url>
120
+ <shipment_status_updates>0</shipment_status_updates>
121
+ <sort_order>10</sort_order>
122
+ <model>shiphawk_shipping/carrier</model>
123
+ <item_is_packed>1</item_is_packed>
124
+ <sort_order>10</sort_order>
125
+ <sallowspecific>1</sallowspecific>
126
+ <gateway_url>https://shiphawk.com/api/v1/</gateway_url>
127
+ </shiphawk_shipping>
128
+ </carriers>
129
+ </default>
130
+ </config>
app/code/community/Shiphawk/Shipping/etc/system.xml ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <carriers>
5
+ <groups>
6
+ <shiphawk_shipping translate="label">
7
+ <label>ShipHawk</label>
8
+ <sort_order>2</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>0</show_in_website>
11
+ <show_in_store>0</show_in_store>
12
+ <fields>
13
+ <active translate="label">
14
+ <label>Enabled</label>
15
+ <frontend_type>select</frontend_type>
16
+ <source_model>adminhtml/system_config_source_yesno</source_model>
17
+ <sort_order>10</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>0</show_in_website>
20
+ <show_in_store>0</show_in_store>
21
+ </active>
22
+ <api_key translate="label">
23
+ <label>Api Key</label>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>20</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>0</show_in_website>
28
+ <show_in_store>0</show_in_store>
29
+ </api_key>
30
+ <!--<gateway_url translate="label">
31
+ <label>Gateway URL</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>21</sort_order>
34
+ <comment>Use https://shiphawk.com/api/v1/ for production. Use https://sandbox.shiphawk.com/api/v1/ for test mode.</comment>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>0</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </gateway_url>-->
39
+ <gateway_url translate="label">
40
+ <label>Gateway Mode</label>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>shiphawk_shipping/source_gateway</source_model>
43
+ <sort_order>21</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>0</show_in_website>
46
+ <show_in_store>0</show_in_store>
47
+ </gateway_url>
48
+ <rate_filter translate="label">
49
+ <label>Rate Filter</label>
50
+ <frontend_type>select</frontend_type>
51
+ <source_model>shiphawk_shipping/source_ratefilter</source_model>
52
+ <sort_order>22</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>0</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ </rate_filter>
57
+ <!--<required_attribute translate="label">
58
+ <label>Required Attributes?</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>30</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>0</show_in_website>
64
+ <show_in_store>0</show_in_store>
65
+ </required_attribute>-->
66
+ <item_is_packed translate="label">
67
+ <label>Default packing setting</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>adminhtml/system_config_source_yesno</source_model>
70
+ <sort_order>40</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>0</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </item_is_packed>
75
+ <book_shipment translate="label">
76
+ <label>Manual book shipment</label>
77
+ <frontend_type>select</frontend_type>
78
+ <source_model>adminhtml/system_config_source_yesno</source_model>
79
+ <sort_order>61</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>0</show_in_website>
82
+ <show_in_store>0</show_in_store>
83
+ </book_shipment>
84
+ <order_received translate="label">
85
+ <label>Send order receipts to:</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>shiphawk_shipping/source_received</source_model>
88
+ <sort_order>62</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>0</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ </order_received>
93
+ <shipment_status_updates translate="label">
94
+ <label>Email status updates to customer?</label>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>adminhtml/system_config_source_yesno</source_model>
97
+ <comment>There can be many updates for each shipment</comment>
98
+ <sort_order>63</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>0</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ </shipment_status_updates>
103
+ <updates_tracking_url translate="label">
104
+ <label>Email tracking URL to customer?</label>
105
+ <frontend_type>select</frontend_type>
106
+ <source_model>adminhtml/system_config_source_yesno</source_model>
107
+ <sort_order>64</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>0</show_in_website>
110
+ <show_in_store>0</show_in_store>
111
+ </updates_tracking_url>
112
+ <sallowspecific translate="label">
113
+ <label>Available for specific countries only</label>
114
+ <frontend_type>select</frontend_type>
115
+ <frontend_class>shipping-applicable-country</frontend_class>
116
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
117
+ <sort_order>70</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>0</show_in_website>
120
+ <show_in_store>0</show_in_store>
121
+ </sallowspecific>
122
+ <specificcountry translate="label">
123
+ <label>Ship to Specific Countries</label>
124
+ <frontend_type>multiselect</frontend_type>
125
+ <sort_order>71</sort_order>
126
+ <source_model>adminhtml/system_config_source_country</source_model>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>0</show_in_website>
129
+ <show_in_store>0</show_in_store>
130
+ <can_be_empty>1</can_be_empty>
131
+ </specificcountry>
132
+ <origin_first_name translate="label">
133
+ <label>Origin First Name</label>
134
+ <frontend_type>text</frontend_type>
135
+ <sort_order>80</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>0</show_in_website>
138
+ <show_in_store>0</show_in_store>
139
+ </origin_first_name>
140
+ <origin_last_name translate="label">
141
+ <label>Origin Last Name</label>
142
+ <frontend_type>text</frontend_type>
143
+ <sort_order>81</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>0</show_in_website>
146
+ <show_in_store>0</show_in_store>
147
+ </origin_last_name>
148
+ <origin_address translate="label">
149
+ <label>Origin Address</label>
150
+ <frontend_type>text</frontend_type>
151
+ <sort_order>82</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>0</show_in_website>
154
+ <show_in_store>0</show_in_store>
155
+ </origin_address>
156
+ <origin_address2 translate="label">
157
+ <label>Origin Address 2</label>
158
+ <frontend_type>text</frontend_type>
159
+ <sort_order>83</sort_order>
160
+ <show_in_default>1</show_in_default>
161
+ <show_in_website>0</show_in_website>
162
+ <show_in_store>0</show_in_store>
163
+ </origin_address2>
164
+ <origin_city translate="label">
165
+ <label>Origin City</label>
166
+ <frontend_type>text</frontend_type>
167
+ <sort_order>84</sort_order>
168
+ <show_in_default>1</show_in_default>
169
+ <show_in_website>0</show_in_website>
170
+ <show_in_store>0</show_in_store>
171
+ </origin_city>
172
+ <origin_state translate="label">
173
+ <label>Origin State</label>
174
+ <frontend_type>text</frontend_type>
175
+ <comment>2 letter abbrev.</comment>
176
+ <sort_order>84</sort_order>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>0</show_in_website>
179
+ <show_in_store>0</show_in_store>
180
+ </origin_state>
181
+ <origin_city translate="label">
182
+ <label>Origin City</label>
183
+ <frontend_type>text</frontend_type>
184
+ <sort_order>85</sort_order>
185
+ <show_in_default>1</show_in_default>
186
+ <show_in_website>0</show_in_website>
187
+ <show_in_store>0</show_in_store>
188
+ </origin_city>
189
+ <default_origin translate="label">
190
+ <label>Default Origin Zipcode </label>
191
+ <frontend_type>text</frontend_type>
192
+ <sort_order>86</sort_order>
193
+ <show_in_default>1</show_in_default>
194
+ <show_in_website>0</show_in_website>
195
+ <show_in_store>0</show_in_store>
196
+ </default_origin>
197
+ <origin_location_type translate="label">
198
+ <label>Origin Location Type</label>
199
+ <frontend_type>select</frontend_type>
200
+ <source_model>shiphawk_shipping/source_location</source_model>
201
+ <sort_order>87</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>0</show_in_website>
204
+ <show_in_store>0</show_in_store>
205
+ </origin_location_type>
206
+ <origin_phone translate="label">
207
+ <label>Origin Phone</label>
208
+ <frontend_type>text</frontend_type>
209
+ <sort_order>88</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>0</show_in_website>
212
+ <show_in_store>0</show_in_store>
213
+ </origin_phone>
214
+ <origin_email translate="label">
215
+ <label>Origin Email </label>
216
+ <frontend_type>text</frontend_type>
217
+ <sort_order>89</sort_order>
218
+ <show_in_default>1</show_in_default>
219
+ <show_in_website>0</show_in_website>
220
+ <show_in_store>0</show_in_store>
221
+ </origin_email>
222
+ </fields>
223
+ </shiphawk_shipping>
224
+ </groups>
225
+ </carriers>
226
+ </sections>
227
+ </config>
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
3
+ $installer->startSetup();
4
+
5
+ $type_of_product_data = array (
6
+ 'attribute_set' => 'Default',
7
+ 'group' => 'ShipHawk Attributes',
8
+ 'label' => 'Type of Item',
9
+ 'visible' => true,
10
+ 'type' => 'varchar',
11
+ /*'input_renderer' => 'shiphawk_shipping/catalog_product_helper_form_type',//definition of renderer*/
12
+ 'input' => 'text',
13
+ 'system' => false,
14
+ 'required' => false,
15
+ 'user_defined' => 1,
16
+ );
17
+
18
+ $installer->addAttribute('catalog_product','shiphawk_type_of_product',$type_of_product_data);
19
+
20
+ $shiphawk_quantity_data = array (
21
+ 'attribute_set' => 'Default',
22
+ 'group' => 'ShipHawk Attributes',
23
+ 'label' => 'Number of items per Product',
24
+ 'visible' => true,
25
+ 'type' => 'int',
26
+ 'input' => 'text',
27
+ 'default' => 1,
28
+ 'frontend_class' => 'validate-not-negative-number',
29
+ 'system' => false,
30
+ 'required' => false,
31
+ 'user_defined' => 1,
32
+ );
33
+
34
+ $installer->addAttribute('catalog_product','shiphawk_quantity', $shiphawk_quantity_data);
35
+
36
+ $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'shiphawk_item_is_packed', array(
37
+ 'group' => 'ShipHawk Attributes',
38
+ 'backend' => 'catalog/product_attribute_backend_msrp',
39
+ 'label' => 'Packaged?',
40
+ 'input' => 'select',
41
+ /*'source' => 'eav/entity_attribute_source_boolean',*/
42
+ 'source' => 'catalog/product_attribute_source_msrp_type_enabled',
43
+ 'type' => 'varchar',
44
+ 'visible' => true,
45
+ 'required' => false,
46
+ 'user_defined' => 1,
47
+ 'default' => '2',
48
+ 'input_renderer' => 'adminhtml/catalog_product_helper_form_msrp_enabled',
49
+ 'visible_on_front' => false
50
+ ));
51
+
52
+ $length_data = array (
53
+ 'attribute_set' => 'Default',
54
+ 'group' => 'ShipHawk Attributes',
55
+ 'label' => 'Length',
56
+ 'visible' => true,
57
+ 'type' => 'varchar',
58
+ 'input' => 'text',
59
+ 'system' => false,
60
+ 'required' => false,
61
+ 'user_defined' => 1,
62
+ );
63
+
64
+ $installer->addAttribute('catalog_product','shiphawk_length',$length_data);
65
+
66
+ $width_data = array (
67
+ 'attribute_set' => 'Default',
68
+ 'group' => 'ShipHawk Attributes',
69
+ 'label' => 'Width',
70
+ 'visible' => true,
71
+ 'type' => 'varchar',
72
+ 'input' => 'text',
73
+ 'system' => false,
74
+ 'required' => false,
75
+ 'user_defined' => 1,
76
+ );
77
+
78
+ $installer->addAttribute('catalog_product','shiphawk_width',$width_data);
79
+
80
+ $height_data = array (
81
+ 'attribute_set' => 'Default',
82
+ 'group' => 'ShipHawk Attributes',
83
+ 'label' => 'Height',
84
+ 'visible' => true,
85
+ 'type' => 'varchar',
86
+ 'input' => 'text',
87
+ 'system' => false,
88
+ 'required' => false,
89
+ 'user_defined' => 1,
90
+ );
91
+
92
+ $installer->addAttribute('catalog_product','shiphawk_height',$height_data);
93
+
94
+ $item_value_data = array (
95
+ 'attribute_set' => 'Default',
96
+ 'group' => 'ShipHawk Attributes',
97
+ 'label' => 'Item Value',
98
+ 'visible' => true,
99
+ 'type' => 'varchar',
100
+ 'frontend_class' => 'validate-number',
101
+ 'input' => 'text',
102
+ 'system' => false,
103
+ 'required' => false,
104
+ 'user_defined' => 1,
105
+ );
106
+
107
+ $installer->addAttribute('catalog_product','shiphawk_item_value', $item_value_data);
108
+
109
+ /* use as separator too */
110
+ $type_of_product_value = array (
111
+ 'attribute_set' => 'Default',
112
+ 'group' => 'ShipHawk Attributes',
113
+ 'label' => 'Origin Contact:',
114
+ 'visible' => true,
115
+ 'type' => 'varchar',
116
+ /*'input_renderer' => 'shiphawk_shipping/catalog_product_helper_form_disabled',//definition of renderer*/
117
+ 'input' => 'text',
118
+ 'system' => false,
119
+ 'required' => false,
120
+ 'user_defined' => 1,
121
+ );
122
+
123
+ $installer->addAttribute('catalog_product','shiphawk_type_of_product_value',$type_of_product_value);
124
+
125
+
126
+ $firstname_origin_data = array (
127
+ 'attribute_set' => 'Default',
128
+ 'group' => 'ShipHawk Attributes',
129
+ 'label' => 'Origin First Name',
130
+ 'visible' => true,
131
+ 'type' => 'varchar',
132
+ 'input' => 'text',
133
+ 'system' => false,
134
+ 'required' => false,
135
+ 'user_defined' => 1,
136
+ );
137
+
138
+ $installer->addAttribute('catalog_product','shiphawk_origin_firstname',$firstname_origin_data);
139
+
140
+ $last_name_origin_data = array (
141
+ 'attribute_set' => 'Default',
142
+ 'group' => 'ShipHawk Attributes',
143
+ 'label' => 'Origin Last Name',
144
+ 'visible' => true,
145
+ 'type' => 'varchar',
146
+ 'input' => 'text',
147
+ 'system' => false,
148
+ 'required' => false,
149
+ 'user_defined' => 1,
150
+ );
151
+
152
+ $installer->addAttribute('catalog_product','shiphawk_origin_lastname',$last_name_origin_data);
153
+
154
+ $address_line_1_origin_data = array (
155
+ 'attribute_set' => 'Default',
156
+ 'group' => 'ShipHawk Attributes',
157
+ 'label' => 'Origin Address',
158
+ 'visible' => true,
159
+ 'type' => 'varchar',
160
+ 'input' => 'text',
161
+ 'system' => false,
162
+ 'required' => false,
163
+ 'user_defined' => 1,
164
+ );
165
+
166
+ $installer->addAttribute('catalog_product','shiphawk_origin_addressline1',$address_line_1_origin_data);
167
+
168
+ $city_origin_data = array (
169
+ 'attribute_set' => 'Default',
170
+ 'group' => 'ShipHawk Attributes',
171
+ 'label' => 'Origin City',
172
+ 'visible' => true,
173
+ 'type' => 'varchar',
174
+ 'input' => 'text',
175
+ 'system' => false,
176
+ 'required' => false,
177
+ 'user_defined' => 1,
178
+ );
179
+
180
+ $installer->addAttribute('catalog_product','shiphawk_origin_city',$city_origin_data);
181
+
182
+ $state_origin_data = array (
183
+ 'attribute_set' => 'Default',
184
+ 'group' => 'ShipHawk Attributes',
185
+ 'label' => 'State',
186
+ 'visible' => true,
187
+ 'type' => 'varchar',
188
+ 'input' => 'text',
189
+ 'system' => false,
190
+ 'required' => false,
191
+ 'user_defined' => 1,
192
+ );
193
+
194
+ $installer->addAttribute('catalog_product','shiphawk_origin_state',$state_origin_data);
195
+
196
+ $zip_code_origin_data = array (
197
+ 'attribute_set' => 'Default',
198
+ 'group' => 'ShipHawk Attributes',
199
+ 'label' => 'Origin Zipcode',
200
+ 'visible' => true,
201
+ 'type' => 'varchar',
202
+ 'input' => 'text',
203
+ 'system' => false,
204
+ 'required' => false,
205
+ 'user_defined' => 1,
206
+ );
207
+
208
+ $installer->addAttribute('catalog_product','shiphawk_origin_zipcode',$zip_code_origin_data);
209
+
210
+ $phone_num_origin_data = array (
211
+ 'attribute_set' => 'Default',
212
+ 'group' => 'ShipHawk Attributes',
213
+ 'label' => 'Origin Phone',
214
+ 'visible' => true,
215
+ 'type' => 'varchar',
216
+ 'input' => 'text',
217
+ 'system' => false,
218
+ 'required' => false,
219
+ 'user_defined' => 1,
220
+ );
221
+
222
+ $installer->addAttribute('catalog_product','shiphawk_origin_phonenum',$phone_num_origin_data);
223
+
224
+ $installer->endSetup();
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.0-0.7.1.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var Mage_Eav_Model_Entity_Setup $installer */
3
+ $installer = Mage::getResourceModel('sales/setup','sales_setup');
4
+ $installer->startSetup();
5
+
6
+ $installer->addAttribute('order', 'shiphawk_book_id', array('type' => 'text', 'input' => 'text'));
7
+ $installer->getConnection()->addColumn($installer->getTable('sales_flat_order'), 'shiphawk_book_id', 'text');
8
+
9
+ $installer->endSetup();
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.1-0.7.2.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
3
+ $installer->startSetup();
4
+
5
+ $location_origin_data = array (
6
+ 'attribute_set' => 'Default',
7
+ 'group' => 'ShipHawk Attributes',
8
+ 'label' => 'Origin Location Type',
9
+ 'visible' => true,
10
+ /*'source' => 'shiphawk_shipping/product_attribute_source_location',*/
11
+ /*'option' =>
12
+ array (
13
+ 'values' =>
14
+ array (
15
+ 'commercial' => 'commercial',
16
+ 'residential' => 'residential'
17
+ ),
18
+ ),*/
19
+ 'option' => array ('value' => array(
20
+ 'commercial' => array('commercial'),
21
+ 'residential' => array('residential'),
22
+ )
23
+ ),
24
+ 'type' => 'varchar',
25
+ 'input' => 'select',
26
+ 'system' => false,
27
+ 'required' => false,
28
+ 'user_defined' => 1,
29
+ );
30
+
31
+ $installer->addAttribute('catalog_product', 'shiphawk_origin_location', $location_origin_data);
32
+
33
+ $installer->endSetup();
app/code/community/Shiphawk/Shipping/sql/shiphawk_setup/mysql4-upgrade-0.7.2-1.0.0.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
3
+ $installer->startSetup();
4
+
5
+ $address_line_2_origin_data = array (
6
+ 'attribute_set' => 'Default',
7
+ 'group' => 'ShipHawk Attributes',
8
+ 'label' => 'Origin Address 2',
9
+ 'visible' => true,
10
+ 'type' => 'varchar',
11
+ 'input' => 'text',
12
+ 'system' => false,
13
+ 'required' => false,
14
+ 'user_defined' => 1,
15
+ );
16
+
17
+ $installer->addAttribute('catalog_product','shiphawk_origin_addressline2',$address_line_2_origin_data);
18
+
19
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/shiphawk.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ <adminhtml_catalog_product_edit>
5
+
6
+ <reference name="head">
7
+
8
+ <action method="addJs"><script>shiphawk/shiphawk.js</script></action>
9
+
10
+ <action method="addItem"><type>js_css</type><name>shiphawk/shiphawk.css</name></action>
11
+
12
+ </reference>
13
+ </adminhtml_catalog_product_edit>
14
+
15
+ <adminhtml_catalog_product_new>
16
+ <reference name="head">
17
+
18
+ <action method="addJs"><script>shiphawk/shiphawk.js</script></action>
19
+
20
+ <action method="addItem"><type>js_css</type><name>shiphawk/shiphawk.css</name></action>
21
+
22
+ </reference>
23
+ </adminhtml_catalog_product_new>
24
+
25
+ </layout>
app/etc/modules/Shiphawk_Shipping.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Shiphawk_Shipping>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Shipping />
9
+ </depends>
10
+ </Shiphawk_Shipping>
11
+ </modules>
12
+ </config>
js/shiphawk/shiphawk.css ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #shiphawk_type_of_product_value {
2
+ display: none;
3
+ }
4
+
5
+ .type_link:hover {
6
+ text-decoration: underline;
7
+ cursor: pointer;
8
+ }
9
+
10
+ #type_product {
11
+ position: absolute;
12
+ z-index: 99;
13
+ background-color: #ffffff;
14
+ }
js/shiphawk/shiphawk.js ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.observe("dom:loaded", function() {
2
+ function insertAfter(referenceNode, newNode) {
3
+ referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
4
+ }
5
+
6
+ var el = document.createElement("div");
7
+
8
+ el.id = "type_product";
9
+ var shiphawk_type_of_product = document.getElementById("shiphawk_type_of_product");
10
+
11
+ insertAfter(shiphawk_type_of_product, el);
12
+
13
+ var typeloader;
14
+ $('shiphawk_type_of_product').observe('keyup', function(event){
15
+ clearTimeout(typeloader);
16
+ typeloader = setTimeout(function(){ respondToClick(event); }, 750);
17
+ });
18
+
19
+ function respondToClick(event) {
20
+
21
+ var element = event.element();
22
+
23
+ var minlength = 3;
24
+
25
+ var url = '/shiphawk/index/search';
26
+
27
+ var parameters = {
28
+ search_tag: element.value
29
+ };
30
+
31
+ if(element.value.length >= minlength ) {
32
+ new Ajax.Request(url, {
33
+ method: 'post',
34
+ parameters: parameters,
35
+ onSuccess: function(transport) {
36
+
37
+ responce_html = JSON.parse(transport.responseText);
38
+
39
+ if(responce_html.shiphawk_error) {
40
+ alert(responce_html.shiphawk_error);
41
+ }else{
42
+ if(responce_html.responce_html) {
43
+ $('type_product').update(responce_html.responce_html);
44
+ $('type_product').show();
45
+ }
46
+ }
47
+
48
+ },
49
+ onLoading:function(transport)
50
+ {
51
+ }
52
+ });
53
+ }
54
+ }
55
+ });
56
+ function setItemid(el) {
57
+ $('shiphawk_type_of_product').value = el.innerHTML;
58
+ $('shiphawk_type_of_product_value').value = el.id;
59
+ $('type_product').hide();
60
+ }
61
+
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ShipHawk</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension allows ShipHawk clients to integrate quickly and easily with their Magento platform so that they can get rates, provide shipping details to customers browsing their website, automatically fulfill shipments thru ShipHawk and get tracking updates all from their existing Magento platform.</summary>
10
+ <description>This extension works with Products, Orders, and Shipments to create a seamless shipping experience for Magento users and their clients. Clients can map their inventory to ShipHawk and get rates on their product listing pages and shopping cart checkout flow. &#xD;
11
+ &#xD;
12
+ ShipHawk fulfillment services let businesses elect to automatically dispatch jobs to ShipHawk or manually book them after their customers have checked out online. The admin can subscribe to tracking updates to programmatically retrieve updates from ShipHawk about their booked shipments. Magento users can leverage out of the box Magento functionality to email details of shipments to their customers and provide tracking details to their end users. &#xD;
13
+ &#xD;
14
+ Clients using Magento no longer have to use ShipHawk APIs to develop their own custom Magento soluion. Now, they can integrate the ShipHawk Magento extension to quickly and easily sync with their existing platform to get rates, provide shipping details to customers browsing their website, automatically fulfill shipments thru ShipHawk and get tracking updates. For more information on ShipHawk, visit https://shiphawk.com </description>
15
+ <notes>v1.0.0 is ShipHawk's initial production release for Magento clients that allows interaction with ShipHawk test and production environments.</notes>
16
+ <authors><author><name>Mikel Richardson</name><user>MAG002779924</user><email>mikel@shiphawk.com</email></author></authors>
17
+ <date>2015-02-25</date>
18
+ <time>20:28:40</time>
19
+ <contents><target name="magecommunity"><dir name="Shiphawk"><dir name="Shipping"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Shipment"><file name="View.php" hash="1f8927cd8ca15d332885274a2be6d47c"/></dir><file name="View.php" hash="ff93e5d161e34830d5ee39cd6ab4f47f"/></dir></dir></dir><dir name="Catalog"><dir name="Product"><dir name="Helper"><dir name="Form"><file name="Disabled.php" hash="05adb96db0b68dc900174c4fefa3b39d"/><file name="Type.php" hash="4dd966de022cc9fc6d69dc5e0ecb4726"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7f6025355f833f98e86ec2cb45ab07a7"/></dir><dir name="Model"><file name="Api.php" hash="29950f03a5d0d1eded903dac8235b2e2"/><file name="Carrier.php" hash="76a17dd5fa14c395b34562bca7733b88"/><file name="Observer.php" hash="88faa75f5412512fee9ed8a9d05aa838"/><dir name="Product"><dir name="Attribute"><dir name="Source"><file name="Location.php" hash="e8cefabd60ff8ef6b09559c35ae4ff8c"/></dir></dir></dir><dir name="Source"><file name="Gateway.php" hash="be5f581f7d0832ea81f78bb4ce5265db"/><file name="Location.php" hash="222ee55e43cc161204bc05e1a08b3db6"/><file name="Ratefilter.php" hash="add461ce1e503d0e7ca042b7c771373e"/><file name="Received.php" hash="6d50e8c1fe6e13c971ba63348e98aac0"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ShipmentController.php" hash="e5fef450f18f1e8ea789e4c837dd8119"/></dir><file name="IndexController.php" hash="0c809600e9525aad328ee343dfd2018b"/></dir><dir name="etc"><file name="config.xml" hash="1d7abd0f38a88cdd617e5d0d56f0fe00"/><file name="system.xml" hash="bbdb9abf438c64e7bd886adad0545cf9"/></dir><dir name="sql"><dir name="shiphawk_setup"><file name="mysql4-install-0.1.0.php" hash="291097bf0be5dfcdcb6d34fff73e1807"/><file name="mysql4-upgrade-0.7.0-0.7.1.php" hash="eb3f0b3185cce381ea63a0d7fa4c76c6"/><file name="mysql4-upgrade-0.7.1-0.7.2.php" hash="6a4bd7c2ff87148fef5315fed9fff478"/><file name="mysql4-upgrade-0.7.2-1.0.0.php" hash="df9dd0c72e585026acdc474372bddcba"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="shiphawk.xml" hash="0498073bc0f7c379521aefc029098456"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shiphawk_Shipping.xml" hash="95b23c165b0c7aa1a96f349aedcb82f3"/></dir></target><target name="mageweb"><dir name="js"><dir name="shiphawk"><file name="shiphawk.css" hash="f7181d7a8ae54c213e08743e196b8145"/><file name="shiphawk.js" hash="5e4aa1cc0ff69ad6cf9b0af73e74b221"/></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>