Intelipost - Version 1.1.0.3

Version Notes

- Weight problems solved and creating just one volume per cart.

Download this release

Release Info

Developer Intelipost
Extension Intelipost
Version 1.1.0.3
Comparing to
See all releases


Code changes from version 1.1.0.1 to 1.1.0.3

app/code/local/Intelipost/Shipping/Model/Carrier/Intelipost.php CHANGED
@@ -38,8 +38,7 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
38
  $destinationZipCode = preg_replace('/[^0-9]/', '', $destinationZipCode);
39
 
40
  $weight = $request->getPackageWeight();
41
-
42
- Mage::log('WEIGHT: '.$weight, null, 'intelipost.log', true);
43
  if ($weight <= 0) {
44
  $this->_throwError('weightzeroerror', 'Weight zero', __LINE__);
45
  }
@@ -79,47 +78,61 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
79
 
80
  $i = 0;
81
  $total_weight = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
- foreach ($item_list as $item) {
84
- $product = $item->getProduct();
 
 
 
 
85
 
86
- $volume = new Intelipost_Model_Request_Volume();
87
- $volume->volume_type = 'BOX';
88
 
89
- if (!$this->isDimensionSet($product)) {
90
- //Mage::log('Product does not have dimensions set', null, 'intelipost.log', true);
91
-
92
- $volume->width = $this->getConfigData('largura_padrao'); // putting default config values here if product width is empty
93
- $volume->height = $this->getConfigData('altura_padrao'); // putting default config values here if product height is empty
94
- $volume->length = $this->getConfigData('comprimento_padrao'); // putting default config values here if product length is empty
95
-
96
- // if ($dimension_check) {
97
- // $this->notifyProductsDimension($item_list);
98
- //return false;
99
- // }
100
  } else {
101
- $volume->width = $product->getVolumeLargura();
102
- $volume->height = $product->getVolumeAltura();
103
- $volume->length = $product->getVolumeComprimento();
 
 
 
104
  }
105
 
106
- //$volume->weight = number_format(floatval($item->getWeight()), 2, ',', '') * $item->getQty();
107
- //$total_weight += number_format(floatval($item->getWeight()), 2, ',', '') * $item->getQty();
108
-
109
- $volume->weight = $weight;
110
- $volume->cost_of_goods = number_format(floatval($item->getPrice()), 2, ',', '') * $item->getQty();
111
 
112
- array_push($quote->volumes, $volume);
113
- }
 
 
 
 
 
 
114
 
115
- $request = json_encode($quote);
116
 
117
  // INTELIPOST QUOTE
118
  $responseBody = $this->intelipostRequest($api_url, $api_key, "/quote", $request);
119
  $response = json_decode($responseBody);
120
  $result = Mage::getModel('shipping/rate_result');
121
 
122
- if($response->content->delivery_options) { // if api responds fine
123
  foreach ($response->content->delivery_options as $deliveryOption) {
124
  $method = Mage::getModel('shipping/rate_result_method');
125
 
@@ -328,8 +341,8 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
328
 
329
  curl_close($s);
330
 
331
- // Mage::log('Request: '.$request, null, 'intelipost.log', true);
332
- // Mage::log('Response: '.$response, null, 'intelipost.log', true);
333
  return $response;
334
  }
335
 
38
  $destinationZipCode = preg_replace('/[^0-9]/', '', $destinationZipCode);
39
 
40
  $weight = $request->getPackageWeight();
41
+
 
42
  if ($weight <= 0) {
43
  $this->_throwError('weightzeroerror', 'Weight zero', __LINE__);
44
  }
78
 
79
  $i = 0;
80
  $total_weight = 0;
81
+ // Volume calculation for a package
82
+ foreach ( $request->getAllItems() as $item) {
83
+
84
+ $product = $item->getProduct();
85
+ if($product->isConfigurable()== true){
86
+ //$teste=$product->isConfigurable();
87
+ //Mage::log('configuravel: '.$product->isConfigurable() , null, 'intelipost.log', true);
88
+ continue;
89
+ }
90
+ $prod_width= $item->getProduct()->getVolumeLargura();
91
+ $prod_length= $item->getProduct()->getVolumeComprimento();
92
+ $prod_height= $item->getProduct()->getVolumeAltura();
93
+
94
+
95
+ $total_volume += $prod_width * $prod_length * $prod_height * $item->getQty();
96
+ //Mage::log('volume: '.$total_volume , null, 'intelipost.log', true);
97
+ //Mage::log('volume: '.$volumecubic , null, 'intelipost.log', true);
98
+ //$volume->weight = number_format(floatval($item->getWeight()), 2, ',', '') * $item->getQty();
99
+ }
100
 
101
+ if ($total_volume ==0 ) {
102
+ // Mage::log('Product does not have dimensions set', null, 'intelipost.log', true);
103
+
104
+ $pack_width = $this->getConfigData('largura_padrao'); // putting default config values here if product width is empty
105
+ $pack_height = $this->getConfigData('altura_padrao'); // putting default config values here if product height is empty
106
+ $pack_length = $this->getConfigData('comprimento_padrao'); // putting default config values here if product length is empty
107
 
 
 
108
 
 
 
 
 
 
 
 
 
 
 
 
109
  } else {
110
+ $volume_bycubic = pow($total_volume, 1/3);
111
+ $volume_bycubic = number_format($volume_bycubic, 2, '.', '');
112
+ //Mage::log('volume: '.$volume_bycubic , null, 'intelipost.log', true);
113
+ $pack_width = $volume_bycubic;
114
+ $pack_height = $volume_bycubic;
115
+ $pack_length = $volume_bycubic;
116
  }
117
 
 
 
 
 
 
118
 
119
+ $volume = new Intelipost_Model_Request_Volume();
120
+ $volume->volume_type = 'BOX';
121
+ $volume->weight = $weight;
122
+ $volume->width = $pack_width;
123
+ $volume->height = $pack_height;
124
+ $volume->length = $pack_length;
125
+ $volume->cost_of_goods = floatval($price);
126
+ array_push($quote->volumes, $volume);
127
 
128
+ $request = json_encode($quote);
129
 
130
  // INTELIPOST QUOTE
131
  $responseBody = $this->intelipostRequest($api_url, $api_key, "/quote", $request);
132
  $response = json_decode($responseBody);
133
  $result = Mage::getModel('shipping/rate_result');
134
 
135
+ if($response->status == "OK") { // if api responds fine
136
  foreach ($response->content->delivery_options as $deliveryOption) {
137
  $method = Mage::getModel('shipping/rate_result_method');
138
 
341
 
342
  curl_close($s);
343
 
344
+ //Mage::log('REQUEST '.$request, null, 'intelipost.log', true);
345
+ //Mage::log('RESPONSE '.$response, null, 'intelipost.log', true);
346
  return $response;
347
  }
348
 
app/code/local/Intelipost/Shipping/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <config>
4
  <modules>
5
  <Intelipost_Shipping>
6
- <version>1.1.0.1</version>
7
  </Intelipost_Shipping>
8
  </modules>
9
 
3
  <config>
4
  <modules>
5
  <Intelipost_Shipping>
6
+ <version>0.0.1</version>
7
  </Intelipost_Shipping>
8
  </modules>
9
 
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Intelipost</name>
4
- <version>1.1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU General Public License Version 2 (GPLv2)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Intelipost</summary>
10
  <description>Extens&#xE3;o para utilizar o servi&#xE7;o de cota&#xE7;&#xE3;o da intelipost.com.br</description>
11
- <notes>- Corrections with some kind of Products</notes>
12
- <authors><author><name>Intelipost</name><user>intelipost</user><email>ti@intelipost.com.br</email></author></authors>
13
- <date>2014-08-06</date>
14
- <time>18:55:24</time>
15
- <contents><target name="magelocal"><dir name="Intelipost"><dir name="Shipping"><dir name="Block"><file name="Import.php" hash="e0d0f1df8063c8e29e81c6ad7838f049"/></dir><dir name="Helper"><file name="Data.php" hash="7523e254d75d8ec6413164bdfc9484ce"/></dir><dir name="Model"><dir name="Carrier"><file name="Category.php" hash="9e3f8a5013f819dc65c9b84848182c8a"/><file name="Intelipost.php" hash="0c5420405956778fc4c83d513fb2f2df"/></dir><dir name="Config"><file name="Apikey.php" hash="dc718c613cae83f0a7fc7f7d3a9ee4fa"/><file name="Apiurl.php" hash="4517960e32a1f0a92a84ce96ff40c6dd"/><file name="Password.php" hash="a3b0f867850520e637ed6d1561047093"/><file name="Token.php" hash="ae2ef4b4527f06c17061d6c984fa0a28"/><file name="Useraccount.php" hash="89a67edacda5169a4f58590e6ac24006"/></dir><dir name="Resource"><file name="EndCustomer.php" hash="a2109babc9b4fc994ccc8bbc3890efe5"/><file name="Invoice.php" hash="f1f792ed019964038769f4950f8c49e3"/><file name="Quote.php" hash="74f2826810d61c8d584ad02a8c12e82d"/><file name="Setup.php" hash="8f10c3277be3454dbf61abb1fb0b06f4"/><file name="ShipmentOrder.php" hash="83c0a94ecd8c9f913a89b3c81798f653"/><file name="Volume.php" hash="0fc8222182fde7557ac85166855a0c4d"/></dir></dir><dir name="etc"><file name="config.xml" hash="79e179f281f5a0347e34b944784725d2"/><file name="system.xml" hash="7a06e44375bac2a21bfc6efa9eb617c5"/></dir><dir name="sql"><dir name="intelipost_setup"><file name="mysql4-install-0.0.1.php" hash="7cbddb7bad3e35cba43d14d8e2308900"/></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="pt_BR"><file name="Intelipost_Shipping.csv" hash="686737bb3f684fc434bceeeb88ebaee9"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intelipost_Shipping.xml" hash="285e60144ae15077910cb9200038adb9"/></dir></target></contents>
 
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.5.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Intelipost</name>
4
+ <version>1.1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU General Public License Version 2 (GPLv2)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Intelipost</summary>
10
  <description>Extens&#xE3;o para utilizar o servi&#xE7;o de cota&#xE7;&#xE3;o da intelipost.com.br</description>
11
+ <notes>- Weight problems solved and creating just one volume per cart.&#xD;
12
+ </notes>
13
+ <authors><author><name>Intelipost</name><user>intelipost</user><email>it@intelipost.com.br</email></author></authors>
14
+ <date>2014-08-22</date>
15
+ <time>02:44:29</time>
16
+ <contents><target name="magelocal"><dir name="Intelipost"><dir name="Shipping"><dir name="Block"><file name="Import.php" hash="e0d0f1df8063c8e29e81c6ad7838f049"/></dir><dir name="Helper"><file name="Data.php" hash="7523e254d75d8ec6413164bdfc9484ce"/></dir><dir name="Model"><dir name="Carrier"><file name="Category.php" hash="9e3f8a5013f819dc65c9b84848182c8a"/><file name="Intelipost.php" hash="cf437069259f911ebf2b0190ad001c7c"/></dir><dir name="Config"><file name="Apikey.php" hash="dc718c613cae83f0a7fc7f7d3a9ee4fa"/><file name="Apiurl.php" hash="4517960e32a1f0a92a84ce96ff40c6dd"/><file name="Password.php" hash="a3b0f867850520e637ed6d1561047093"/><file name="Token.php" hash="ae2ef4b4527f06c17061d6c984fa0a28"/><file name="Useraccount.php" hash="89a67edacda5169a4f58590e6ac24006"/></dir><dir name="Resource"><file name="EndCustomer.php" hash="a2109babc9b4fc994ccc8bbc3890efe5"/><file name="Invoice.php" hash="f1f792ed019964038769f4950f8c49e3"/><file name="Quote.php" hash="74f2826810d61c8d584ad02a8c12e82d"/><file name="Setup.php" hash="8f10c3277be3454dbf61abb1fb0b06f4"/><file name="ShipmentOrder.php" hash="83c0a94ecd8c9f913a89b3c81798f653"/><file name="Volume.php" hash="0fc8222182fde7557ac85166855a0c4d"/></dir></dir><dir name="etc"><file name="config.xml" hash="68df33ea9de1659f5b2ffea89ea27bc3"/><file name="system.xml" hash="7a06e44375bac2a21bfc6efa9eb617c5"/></dir><dir name="sql"><dir name="intelipost_setup"><file name="mysql4-install-0.0.1.php" hash="7cbddb7bad3e35cba43d14d8e2308900"/></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="pt_BR"><file name="Intelipost_Shipping.csv" hash="686737bb3f684fc434bceeeb88ebaee9"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intelipost_Shipping.xml" hash="285e60144ae15077910cb9200038adb9"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.3.0</min><max>5.5.0</max></php></required></dependencies>
19
  </package>