ShipHero - Version 1.0.1.6

Version Notes

- Fixed shipping method tracking

Download this release

Release Info

Developer Fareed Hosein
Extension ShipHero
Version 1.0.1.6
Comparing to
See all releases


Code changes from version 1.0.1.5 to 1.0.1.6

app/code/community/ShipHero/ShipmentExtApi/Model/Api2/Shipment/Rest/Admin/V1.php CHANGED
@@ -38,6 +38,8 @@ class ShipHero_ShipmentExtApi_Model_Api2_Shipment_Rest_Admin_V1 extends ShipHero
38
  */
39
  protected function _create(array $data)
40
  {
 
 
41
  if(empty($data['order_id']))
42
  {
43
  $this->_critical(self::RESOURCE_REQUEST_DATA_INVALID);
@@ -53,7 +55,7 @@ class ShipHero_ShipmentExtApi_Model_Api2_Shipment_Rest_Admin_V1 extends ShipHero
53
  * which will be sent out by any warehouse to Magento
54
  */
55
  $shipmentTrackingNumber = $data['tracking_number'];
56
-
57
  /**
58
  * This can be blank also.
59
  */
@@ -63,40 +65,54 @@ class ShipHero_ShipmentExtApi_Model_Api2_Shipment_Rest_Admin_V1 extends ShipHero
63
  // $shipment = Mage::getModel('sales/service_order', $order)
64
  // ->prepareShipment($this->_getItemQtys($order, $data['line_items']));
65
  $shipment = Mage::getModel('sales/service_order', $order)
66
- ->prepareShipment($this->_getItemQtys($order, $data['line_items']));
67
-
68
  /**
69
  * Carrier Codes can be like "ups" / "fedex" / "custom",
70
  * but they need to be active from the System Configuration area.
71
  * These variables can be provided custom-value, but it is always
72
  * suggested to use Order values
73
  */
 
 
74
  $shipmentCarrierCode = $data['shipping_carrier'];
75
- $shipmentCarrierTitle = NULL; // $data['shipping_method'];
 
76
  if(!empty($shipmentCarrierCode))
77
  {
78
  $customerEmailComments = 'Shipped via ' . $shipmentCarrierCode;
79
  }
80
-
 
 
 
 
 
 
 
 
 
81
  $arrTracking = array(
82
- 'carrier_code' => isset($shipmentCarrierCode) ? $shipmentCarrierCode : $order->getShippingCarrier()->getCarrierCode(),
83
- 'title' => isset($shipmentCarrierTitle) ? $shipmentCarrierTitle : $order->getShippingCarrier()->getConfigData('title'),
84
  'number' => $shipmentTrackingNumber,
85
  );
86
 
87
  $track = Mage::getModel('sales/order_shipment_track')->addData($arrTracking);
88
  $shipment->addTrack($track);
89
-
90
  // Register Shipment
91
  $shipment->register();
92
-
93
  // Save the Shipment
94
  $this->_saveShipment($shipment, $order, $customerEmailComments);
95
-
96
  // Finally, Save the Order
97
  $this->_saveOrder($order, $customerEmailComments);
98
 
99
  } catch (Exception $e) {
 
 
100
  $this->_error($e->getMessage(), Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
101
  }
102
  }
@@ -128,7 +144,7 @@ class ShipHero_ShipmentExtApi_Model_Api2_Shipment_Rest_Admin_V1 extends ShipHero
128
  protected function _getItemQtys(Mage_Sales_Model_Order $order, $lineItems)
129
  {
130
  $qty = array();
131
-
132
  foreach ($order->getAllItems() as $_eachItem) {
133
  $orderQty = (int)$_eachItem->getQtyOrdered();
134
  $shippedQty = (int)$_eachItem->getQtyShipped();
@@ -147,7 +163,7 @@ class ShipHero_ShipmentExtApi_Model_Api2_Shipment_Rest_Admin_V1 extends ShipHero
147
 
148
  return $qty;
149
  }
150
-
151
  /**
152
  * Saves the Shipment changes in the Order
153
  *
@@ -159,19 +175,26 @@ class ShipHero_ShipmentExtApi_Model_Api2_Shipment_Rest_Admin_V1 extends ShipHero
159
  {
160
  $shipment->getOrder()->setIsInProcess(true);
161
  $transactionSave = Mage::getModel('core/resource_transaction')
162
- ->addObject($shipment)
163
- ->addObject($order)
164
- ->save();
165
-
166
  $emailSentStatus = $shipment->getData('email_sent');
 
 
167
  if (!is_null($customerEmailComments) && !$emailSentStatus) {
168
- $shipment->sendEmail(true, $customerEmailComments);
 
 
 
 
 
169
  $shipment->setEmailSent(true);
170
  }
171
-
172
  return $this;
173
  }
174
-
175
  /**
176
  * Saves the Order, to complete the full life-cycle of the Order
177
  * Order status will now show as Complete
@@ -186,10 +209,10 @@ class ShipHero_ShipmentExtApi_Model_Api2_Shipment_Rest_Admin_V1 extends ShipHero
186
  }
187
  // $order->setData('state', Mage_Sales_Model_Order::STATE_PROCESSING);
188
  // $order->setData('status', Mage_Sales_Model_Order::STATE_PROCESSING);
189
-
190
  $order->save();
191
-
192
  return $this;
193
  }
194
-
195
  }
38
  */
39
  protected function _create(array $data)
40
  {
41
+ // error_log("In create shipment");
42
+ // error_log(print_r($data,1));
43
  if(empty($data['order_id']))
44
  {
45
  $this->_critical(self::RESOURCE_REQUEST_DATA_INVALID);
55
  * which will be sent out by any warehouse to Magento
56
  */
57
  $shipmentTrackingNumber = $data['tracking_number'];
58
+
59
  /**
60
  * This can be blank also.
61
  */
65
  // $shipment = Mage::getModel('sales/service_order', $order)
66
  // ->prepareShipment($this->_getItemQtys($order, $data['line_items']));
67
  $shipment = Mage::getModel('sales/service_order', $order)
68
+ ->prepareShipment($this->_getItemQtys($order, $data['line_items']));
69
+
70
  /**
71
  * Carrier Codes can be like "ups" / "fedex" / "custom",
72
  * but they need to be active from the System Configuration area.
73
  * These variables can be provided custom-value, but it is always
74
  * suggested to use Order values
75
  */
76
+ $originalCarrierCode = strtolower($order->getShippingCarrier()->getCarrierCode());
77
+ $originalCarrierTitle = $order->getShippingCarrier()->getConfigData('title');
78
  $shipmentCarrierCode = $data['shipping_carrier'];
79
+ $shipmentCarrierTitle = $data['shipping_method'];
80
+
81
  if(!empty($shipmentCarrierCode))
82
  {
83
  $customerEmailComments = 'Shipped via ' . $shipmentCarrierCode;
84
  }
85
+ else
86
+ {
87
+ $shipmentCarrierCode = $originalCarrierCode;
88
+ }
89
+
90
+ if(empty($shipmentCarrierTitle))
91
+ {
92
+ $shipmentCarrierTitle = $originalCarrierTitle;
93
+ }
94
+
95
  $arrTracking = array(
96
+ 'carrier_code' => $shipmentCarrierCode,
97
+ 'title' => $shipmentCarrierTitle,
98
  'number' => $shipmentTrackingNumber,
99
  );
100
 
101
  $track = Mage::getModel('sales/order_shipment_track')->addData($arrTracking);
102
  $shipment->addTrack($track);
103
+
104
  // Register Shipment
105
  $shipment->register();
106
+
107
  // Save the Shipment
108
  $this->_saveShipment($shipment, $order, $customerEmailComments);
109
+
110
  // Finally, Save the Order
111
  $this->_saveOrder($order, $customerEmailComments);
112
 
113
  } catch (Exception $e) {
114
+ // error_log("Top level error");
115
+ // error_log($e->getMessage());
116
  $this->_error($e->getMessage(), Mage_Api2_Model_Server::HTTP_BAD_REQUEST);
117
  }
118
  }
144
  protected function _getItemQtys(Mage_Sales_Model_Order $order, $lineItems)
145
  {
146
  $qty = array();
147
+
148
  foreach ($order->getAllItems() as $_eachItem) {
149
  $orderQty = (int)$_eachItem->getQtyOrdered();
150
  $shippedQty = (int)$_eachItem->getQtyShipped();
163
 
164
  return $qty;
165
  }
166
+
167
  /**
168
  * Saves the Shipment changes in the Order
169
  *
175
  {
176
  $shipment->getOrder()->setIsInProcess(true);
177
  $transactionSave = Mage::getModel('core/resource_transaction')
178
+ ->addObject($shipment)
179
+ ->addObject($order)
180
+ ->save();
181
+
182
  $emailSentStatus = $shipment->getData('email_sent');
183
+ // error_log('Email Check');
184
+ // error_log($customerEmailComments . ', ' . $emailSentStatus);
185
  if (!is_null($customerEmailComments) && !$emailSentStatus) {
186
+ try {
187
+ $emailed = $shipment->sendEmail(true, $customerEmailComments);
188
+ }catch (Exception $e){
189
+ error_log("Email Error");
190
+ error_log($e->getMessage());
191
+ }
192
  $shipment->setEmailSent(true);
193
  }
194
+
195
  return $this;
196
  }
197
+
198
  /**
199
  * Saves the Order, to complete the full life-cycle of the Order
200
  * Order status will now show as Complete
209
  }
210
  // $order->setData('state', Mage_Sales_Model_Order::STATE_PROCESSING);
211
  // $order->setData('status', Mage_Sales_Model_Order::STATE_PROCESSING);
212
+
213
  $order->save();
214
+
215
  return $this;
216
  }
217
+
218
  }
app/code/community/ShipHero/WebHooks/.DS_Store ADDED
Binary file
app/code/community/ShipHero/WebHooks/Model/OrderObserver.php CHANGED
@@ -93,39 +93,34 @@ class ShipHero_WebHooks_Model_OrderObserver
93
  $simpleProduct = unserialize($productOptions['product_options']);
94
 
95
  // Loop through our options for the ordered item
96
- foreach($simpleProduct['options'] as $key => $itemOption)
97
  {
98
- // Get product options
99
- foreach($product->getOptions() as $opt)
100
  {
101
- // Get the values for the options
102
- $opts = $opt->getValues();
103
-
104
- // Loop through options and extract the values for the selected item's options
105
- foreach($opts as $o)
106
  {
107
- $oData = $o->getData();
108
- // error_log(print_r($itemOption,1));
109
- // error_log("-----------------------------\n");
110
- // error_log(print_r($oData,1));
111
- // error_log("=============================\n");
112
- // error_log($itemOption['option_id'] . ' = ' . $oData['option_id']);
113
- // error_log($itemOption['print_value'] . ' = ' . $oData['default_title']);
114
- if($itemOption['option_id'] == $oData['option_id'] && $itemOption['print_value'] == $oData['default_title'])
115
  {
116
- // error_log(print_r($oData,1));
117
- $simpleProduct['options'][$key]['sku'] = $oData['sku'];
118
- $simpleProduct['options'][$key]['price'] = $oData['price'];
 
 
 
119
  }
120
- // error_log("===========-------------------===========\n\n");
121
  }
122
  }
123
- }
124
 
125
- $product['name'] = $simpleProduct['simple_name'];
126
- $productData['sku'] = $simpleProduct['simple_sku'];
127
- $product->load($product->getIdBySku($simpleProduct['simple_sku']));
128
- $options['options'] = $simpleProduct['options'];
 
129
  }
130
  $p_name = $this->_getProductName($product);
131
  $item['sku'] = $productData['sku'];
93
  $simpleProduct = unserialize($productOptions['product_options']);
94
 
95
  // Loop through our options for the ordered item
96
+ if(!empty($simpleProduct))
97
  {
98
+ foreach ($simpleProduct['options'] as $key => $itemOption)
 
99
  {
100
+ // Get product options
101
+ foreach ($product->getOptions() as $opt)
 
 
 
102
  {
103
+ // Get the values for the options
104
+ $opts = $opt->getValues();
105
+
106
+ // Loop through options and extract the values for the selected item's options
107
+ foreach ($opts as $o)
 
 
 
108
  {
109
+ $oData = $o->getData();
110
+ if ($itemOption['option_id'] == $oData['option_id'] && $itemOption['print_value'] == $oData['default_title'])
111
+ {
112
+ $simpleProduct['options'][$key]['sku'] = $oData['sku'];
113
+ $simpleProduct['options'][$key]['price'] = $oData['price'];
114
+ }
115
  }
 
116
  }
117
  }
 
118
 
119
+ $product['name'] = $simpleProduct['simple_name'];
120
+ $productData['sku'] = $simpleProduct['simple_sku'];
121
+ $product->load($product->getIdBySku($simpleProduct['simple_sku']));
122
+ $options['options'] = $simpleProduct['options'];
123
+ }
124
  }
125
  $p_name = $this->_getProductName($product);
126
  $item['sku'] = $productData['sku'];
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ShipHero</name>
4
- <version>1.0.1.5</version>
5
  <stability>beta</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
@@ -40,11 +40,11 @@ You can see the status of the order in real time and the history of the order in
40
  &lt;p&gt;Please do! Contact us at 1-(877) 671-6011 or &lt;a href="mailto:hello@shiphero.com"&gt;hello@shiphero.com&lt;/a&gt;&lt;/p&gt;&#xD;
41
  &#xD;
42
  &lt;p /&gt;Want to know more about ShipHero? &lt;a href="http://www.ShipHero.com"&gt;Watch video of ShipHero in action, and learn about the full set of features.&lt;/a&gt;</description>
43
- <notes>- Added Custom Options to product api for configurable products</notes>
44
  <authors><author><name>Fareed Hosein</name><user>shipherollc</user><email>roger@shiphero.com</email></author></authors>
45
- <date>2015-03-20</date>
46
- <time>21:08:45</time>
47
- <contents><target name="magecommunity"><dir name="ShipHero"><dir name="CatalogExtApi"><dir name="Model"><dir name="Api2"><dir name="Product"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="b5d32a3da264d3ae841ac62888016b10"/></dir><file name=".DS_Store" hash="82133767cb30f899e06a57a6c0215a3d"/></dir></dir></dir></dir><dir name="etc"><file name="api2.xml" hash="a84153a82d1ca4b37909cb836fb0df78"/><file name="config.xml" hash="75fca57d73d1909bfb92a0b4116c3b24"/></dir></dir><dir name="CategoriesExtApi"><dir name="Model"><dir name="Api2"><dir name="Categories"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="1b2132443dacf2e8b7bab5e7aef17765"/></dir></dir></dir><file name="Categories.php" hash="a3e20a32e745bf4360019bd18a77cb3d"/></dir></dir><dir name="etc"><file name="api2.xml" hash="3ecd699dcd137862f6b92bc963b3556f"/><file name="config.xml" hash="286f5304b1db4bffe69238ea661af011"/></dir></dir><dir name="PaymentExtApi"><dir name="Model"><dir name="Api2"><dir name="Payment"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="d172248ff949effa3990191c6a037ef3"/></dir></dir></dir><file name="Payment.php" hash="dd379bf5c286b0924111db0a8fadd658"/></dir></dir><dir name="etc"><file name="api2.xml" hash="792e6b7c9f17b551cb327267427ac128"/><file name="config.xml" hash="3a0e38693d058eb48521a4325b761b2e"/></dir></dir><dir name="SalesExtApi"><dir name="Model"><dir name="Api2"><dir name="Order"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="6dc32a11bbafa30b2de231e99afcd6d1"/></dir></dir></dir></dir></dir><dir name="etc"><file name="api2.xml" hash="7fd3830df03511ab3fd8923e9bf490dc"/><file name="config.xml" hash="a0817be74340d9f9e12861993e5ee2c9"/></dir></dir><dir name="ShipmentExtApi"><dir name="Model"><dir name="Api2"><dir name="Shipment"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="0feae5649f1ee7145fb3d5a266e1f2f6"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir><file name="Shipment.php" hash="8a804aecde89f00f4d013253e8526cfb"/></dir></dir><dir name="etc"><file name="api2.xml" hash="84d7bb1a150b5b94f0797403ef656f45"/><file name="config.xml" hash="6bcba4e8b893bb78eadfb6038fa01927"/></dir></dir><dir name="WebHooks"><dir name="Model"><file name="OrderObserver.php" hash="0fb29f895be961700cdd85e23386a940"/><file name="ProductObserver.php" hash="c6da509d06a30fb18f32b2004a1d8893"/><dir name="Resource"><file name="Setup.php" hash="428887c1ea6151a293d3d4b633963bce"/></dir></dir><dir name="etc"><file name="config.xml" hash="e5e8d6595e85311f3617f63b813e8e35"/><dir name="webapi"><file name="acl.xml" hash="444730c8892d9a14c169b6cd96da1cdd"/></dir></dir><dir name="sql"><dir name="shiphero_setup"><file name="install-0.1.0.php" hash="b793368264d3637cb831dd1ec2dbbeae"/></dir></dir></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></target><target name="mageetc"><dir name="modules"><file name="ShipHero.xml" hash="f6f6ffa93e8158fa631eb960d8872d46"/></dir></target></contents>
48
  <compatible/>
49
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0</min><max>2.0.0</max></package></required></dependencies>
50
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>ShipHero</name>
4
+ <version>1.0.1.6</version>
5
  <stability>beta</stability>
6
  <license>GNU General Public License (GPL)</license>
7
  <channel>community</channel>
40
  &lt;p&gt;Please do! Contact us at 1-(877) 671-6011 or &lt;a href="mailto:hello@shiphero.com"&gt;hello@shiphero.com&lt;/a&gt;&lt;/p&gt;&#xD;
41
  &#xD;
42
  &lt;p /&gt;Want to know more about ShipHero? &lt;a href="http://www.ShipHero.com"&gt;Watch video of ShipHero in action, and learn about the full set of features.&lt;/a&gt;</description>
43
+ <notes>- Fixed shipping method tracking</notes>
44
  <authors><author><name>Fareed Hosein</name><user>shipherollc</user><email>roger@shiphero.com</email></author></authors>
45
+ <date>2015-06-01</date>
46
+ <time>03:12:09</time>
47
+ <contents><target name="magecommunity"><dir name="ShipHero"><dir name="CatalogExtApi"><dir name="Model"><dir name="Api2"><dir name="Product"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="b5d32a3da264d3ae841ac62888016b10"/></dir><file name=".DS_Store" hash="82133767cb30f899e06a57a6c0215a3d"/></dir></dir></dir></dir><dir name="etc"><file name="api2.xml" hash="a84153a82d1ca4b37909cb836fb0df78"/><file name="config.xml" hash="75fca57d73d1909bfb92a0b4116c3b24"/></dir></dir><dir name="CategoriesExtApi"><dir name="Model"><dir name="Api2"><dir name="Categories"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="1b2132443dacf2e8b7bab5e7aef17765"/></dir></dir></dir><file name="Categories.php" hash="a3e20a32e745bf4360019bd18a77cb3d"/></dir></dir><dir name="etc"><file name="api2.xml" hash="3ecd699dcd137862f6b92bc963b3556f"/><file name="config.xml" hash="286f5304b1db4bffe69238ea661af011"/></dir></dir><dir name="PaymentExtApi"><dir name="Model"><dir name="Api2"><dir name="Payment"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="d172248ff949effa3990191c6a037ef3"/></dir></dir></dir><file name="Payment.php" hash="dd379bf5c286b0924111db0a8fadd658"/></dir></dir><dir name="etc"><file name="api2.xml" hash="792e6b7c9f17b551cb327267427ac128"/><file name="config.xml" hash="3a0e38693d058eb48521a4325b761b2e"/></dir></dir><dir name="SalesExtApi"><dir name="Model"><dir name="Api2"><dir name="Order"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="6dc32a11bbafa30b2de231e99afcd6d1"/></dir></dir></dir></dir></dir><dir name="etc"><file name="api2.xml" hash="7fd3830df03511ab3fd8923e9bf490dc"/><file name="config.xml" hash="a0817be74340d9f9e12861993e5ee2c9"/></dir></dir><dir name="ShipmentExtApi"><dir name="Model"><dir name="Api2"><dir name="Shipment"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="abdb59626a9bd4af1466159ee2383883"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir></dir><file name="Shipment.php" hash="8a804aecde89f00f4d013253e8526cfb"/></dir></dir><dir name="etc"><file name="api2.xml" hash="84d7bb1a150b5b94f0797403ef656f45"/><file name="config.xml" hash="6bcba4e8b893bb78eadfb6038fa01927"/></dir></dir><dir name="WebHooks"><dir name="Model"><file name="OrderObserver.php" hash="d739ed8ae23069cb668fade2fe87418a"/><file name="ProductObserver.php" hash="c6da509d06a30fb18f32b2004a1d8893"/><dir name="Resource"><file name="Setup.php" hash="428887c1ea6151a293d3d4b633963bce"/></dir></dir><dir name="etc"><file name="config.xml" hash="e5e8d6595e85311f3617f63b813e8e35"/><dir name="webapi"><file name="acl.xml" hash="444730c8892d9a14c169b6cd96da1cdd"/></dir></dir><dir name="sql"><dir name="shiphero_setup"><file name="install-0.1.0.php" hash="b793368264d3637cb831dd1ec2dbbeae"/></dir></dir><file name=".DS_Store" hash="5877fb6bf8ef0d0b1ae94df92d07d4cb"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></target><target name="mageetc"><dir name="modules"><file name="ShipHero.xml" hash="f6f6ffa93e8158fa631eb960d8872d46"/></dir></target></contents>
48
  <compatible/>
49
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0</min><max>2.0.0</max></package></required></dependencies>
50
  </package>