Version Notes
Correção de bug ao selecionar apenas um dos métodos de entrega.
Download this release
Release Info
Developer | Willian |
Extension | correios |
Version | 1.3.1 |
Comparing to | |
See all releases |
Code changes from version 1.3.0 to 1.3.1
app/code/community/Storm/Correios/Model/Carrier/Webservice.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* @category Storm
|
4 |
* @package Storm_Correios
|
5 |
* @copyright Copyright (c) 2013 Willian Cordeiro de Souza
|
6 |
-
* @author Willian Cordeiro de Souza <williancordeirodesouza@gmail.com>
|
7 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
*/
|
9 |
class Storm_Correios_Model_Carrier_Webservice
|
@@ -32,13 +32,13 @@ class Storm_Correios_Model_Carrier_Webservice
|
|
32 |
$this->setParam('nCdEmpresa', $this->_getHelper()->getConfigData('account_code'))
|
33 |
->setParam('sDsSenha', $this->_getHelper()->getConfigData('account_password'))
|
34 |
->setParam('nCdServico', $this->_getHelper()->getConfigData('shipping_methods'))
|
35 |
-
->setParam('sCepOrigem', Mage::getStoreConfig('shipping/origin/postcode'));
|
36 |
}
|
37 |
-
|
38 |
/**
|
39 |
* Gets the instance of the SoapClient
|
40 |
* connected to the webservice
|
41 |
-
*
|
42 |
* @return SoapClient
|
43 |
*/
|
44 |
public function getClient()
|
@@ -49,7 +49,7 @@ class Storm_Correios_Model_Carrier_Webservice
|
|
49 |
/**
|
50 |
* Assign parameters to be sent to
|
51 |
* webservice on request
|
52 |
-
*
|
53 |
* @param string $name
|
54 |
* @param string $value
|
55 |
* @return Storm_Correios_Model_Carrier_Webservice
|
@@ -62,7 +62,7 @@ class Storm_Correios_Model_Carrier_Webservice
|
|
62 |
|
63 |
/**
|
64 |
* Gets all the parameters already setted
|
65 |
-
*
|
66 |
* @return array
|
67 |
*/
|
68 |
public function getParams()
|
@@ -72,7 +72,7 @@ class Storm_Correios_Model_Carrier_Webservice
|
|
72 |
|
73 |
/**
|
74 |
* Gets a value only a specific key
|
75 |
-
*
|
76 |
* @param string $key
|
77 |
* @return boolean | string
|
78 |
*/
|
@@ -84,10 +84,10 @@ class Storm_Correios_Model_Carrier_Webservice
|
|
84 |
|
85 |
return false;
|
86 |
}
|
87 |
-
|
88 |
/**
|
89 |
* Assign the request of the delivery method
|
90 |
-
*
|
91 |
* @param Mage_Shipping_Model_Rate_Request $request
|
92 |
* @return Storm_Correios_Model_Carrier_Webservice
|
93 |
*/
|
@@ -95,7 +95,7 @@ class Storm_Correios_Model_Carrier_Webservice
|
|
95 |
{
|
96 |
$dimension = Mage::getModel('correios/carrier_package_dimension');
|
97 |
$dimension->setRequest($request);
|
98 |
-
|
99 |
$this->setParam('sCepDestino', $request->getDestPostcode())
|
100 |
->setParam('nVlPeso', $request->getPackageWeight())
|
101 |
->setParam('nCdFormato', 1)
|
@@ -106,85 +106,92 @@ class Storm_Correios_Model_Carrier_Webservice
|
|
106 |
->setParam('sCdMaoPropria', $this->_getHelper()->getConfigData('own_hands') ? 'S' : 'N')
|
107 |
->setParam('nVlValorDeclarado', 0)
|
108 |
->setParam('sCdAvisoRecebimento', $this->_getHelper()->getConfigData('receipt_warning') ? 'S' : 'N');
|
109 |
-
|
110 |
-
if($this->_getHelper()->getConfigData('stated_value')) {
|
111 |
$this->setParam('nVlValorDeclarado', $request->getPackageValue());
|
112 |
}
|
113 |
-
|
114 |
$this->_request = $request;
|
115 |
return $this;
|
116 |
}
|
117 |
-
|
118 |
/**
|
119 |
* Gets the request of the delivery method
|
120 |
-
*
|
121 |
* @return Mage_Shipping_Model_Rate_Request
|
122 |
*/
|
123 |
public function getShippingRequest()
|
124 |
{
|
125 |
return $this->_request;
|
126 |
}
|
127 |
-
|
128 |
/**
|
129 |
* Performs a request with webservice of Correios
|
130 |
-
*
|
131 |
* @return array
|
132 |
*/
|
133 |
public function request()
|
134 |
{
|
135 |
if(!$request = $this->getClient()->CalcPrecoPrazo($this->getParams())) {
|
136 |
-
return false;
|
137 |
}
|
138 |
-
|
139 |
if(!$request = $request->CalcPrecoPrazoResult) {
|
140 |
-
return false;
|
141 |
-
}
|
142 |
-
|
143 |
if(!$request = $request->Servicos) {
|
144 |
-
return false;
|
145 |
}
|
146 |
-
|
147 |
if(!$request = $request->cServico) {
|
148 |
-
return false;
|
149 |
-
}
|
150 |
-
|
151 |
-
$result = array();
|
152 |
-
foreach($request as $methodData) {
|
153 |
-
$result[] = $this->_convertWebserviceValues($methodData);
|
154 |
}
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
return $result;
|
157 |
}
|
158 |
-
|
159 |
/**
|
160 |
* Gets the helper module's main
|
161 |
-
*
|
162 |
* @return Storm_Correios_Helper_Data
|
163 |
*/
|
164 |
protected function _getHelper()
|
165 |
{
|
166 |
return Mage::helper('correios');
|
167 |
}
|
168 |
-
|
169 |
/**
|
170 |
* Converts the data returned from webservice to the object
|
171 |
* Varien_Object using the parameter names in English
|
172 |
-
*
|
173 |
* @param stdClass $data
|
174 |
* @return Varien_Object
|
175 |
*/
|
176 |
private function _convertWebserviceValues(stdClass $data)
|
177 |
{
|
178 |
$result = new Varien_Object();
|
179 |
-
$result->setCode($data->Codigo);
|
180 |
-
|
181 |
if($data->Erro != 0) {
|
182 |
$result->setError($data->Erro)
|
183 |
->setErrorMessage($data->MsgErro);
|
184 |
-
|
185 |
return $result;
|
186 |
}
|
187 |
-
|
188 |
$result->setPrice($this->_getHelper()->convertToFloat($data->Valor))
|
189 |
->setDeliveryTime($data->PrazoEntrega + intval($this->_getHelper()->getConfigData('add_delivery_time')))
|
190 |
->setHomeDelivery($data->EntregaDomiciliar == 'S' ? true : false)
|
3 |
* @category Storm
|
4 |
* @package Storm_Correios
|
5 |
* @copyright Copyright (c) 2013 Willian Cordeiro de Souza
|
6 |
+
* @author Willian Cordeiro de Souza <williancordeirodesouza@gmail.com>
|
7 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
*/
|
9 |
class Storm_Correios_Model_Carrier_Webservice
|
32 |
$this->setParam('nCdEmpresa', $this->_getHelper()->getConfigData('account_code'))
|
33 |
->setParam('sDsSenha', $this->_getHelper()->getConfigData('account_password'))
|
34 |
->setParam('nCdServico', $this->_getHelper()->getConfigData('shipping_methods'))
|
35 |
+
->setParam('sCepOrigem', Mage::getStoreConfig('shipping/origin/postcode'));
|
36 |
}
|
37 |
+
|
38 |
/**
|
39 |
* Gets the instance of the SoapClient
|
40 |
* connected to the webservice
|
41 |
+
*
|
42 |
* @return SoapClient
|
43 |
*/
|
44 |
public function getClient()
|
49 |
/**
|
50 |
* Assign parameters to be sent to
|
51 |
* webservice on request
|
52 |
+
*
|
53 |
* @param string $name
|
54 |
* @param string $value
|
55 |
* @return Storm_Correios_Model_Carrier_Webservice
|
62 |
|
63 |
/**
|
64 |
* Gets all the parameters already setted
|
65 |
+
*
|
66 |
* @return array
|
67 |
*/
|
68 |
public function getParams()
|
72 |
|
73 |
/**
|
74 |
* Gets a value only a specific key
|
75 |
+
*
|
76 |
* @param string $key
|
77 |
* @return boolean | string
|
78 |
*/
|
84 |
|
85 |
return false;
|
86 |
}
|
87 |
+
|
88 |
/**
|
89 |
* Assign the request of the delivery method
|
90 |
+
*
|
91 |
* @param Mage_Shipping_Model_Rate_Request $request
|
92 |
* @return Storm_Correios_Model_Carrier_Webservice
|
93 |
*/
|
95 |
{
|
96 |
$dimension = Mage::getModel('correios/carrier_package_dimension');
|
97 |
$dimension->setRequest($request);
|
98 |
+
|
99 |
$this->setParam('sCepDestino', $request->getDestPostcode())
|
100 |
->setParam('nVlPeso', $request->getPackageWeight())
|
101 |
->setParam('nCdFormato', 1)
|
106 |
->setParam('sCdMaoPropria', $this->_getHelper()->getConfigData('own_hands') ? 'S' : 'N')
|
107 |
->setParam('nVlValorDeclarado', 0)
|
108 |
->setParam('sCdAvisoRecebimento', $this->_getHelper()->getConfigData('receipt_warning') ? 'S' : 'N');
|
109 |
+
|
110 |
+
if($this->_getHelper()->getConfigData('stated_value')) {
|
111 |
$this->setParam('nVlValorDeclarado', $request->getPackageValue());
|
112 |
}
|
113 |
+
|
114 |
$this->_request = $request;
|
115 |
return $this;
|
116 |
}
|
117 |
+
|
118 |
/**
|
119 |
* Gets the request of the delivery method
|
120 |
+
*
|
121 |
* @return Mage_Shipping_Model_Rate_Request
|
122 |
*/
|
123 |
public function getShippingRequest()
|
124 |
{
|
125 |
return $this->_request;
|
126 |
}
|
127 |
+
|
128 |
/**
|
129 |
* Performs a request with webservice of Correios
|
130 |
+
*
|
131 |
* @return array
|
132 |
*/
|
133 |
public function request()
|
134 |
{
|
135 |
if(!$request = $this->getClient()->CalcPrecoPrazo($this->getParams())) {
|
136 |
+
return false;
|
137 |
}
|
138 |
+
|
139 |
if(!$request = $request->CalcPrecoPrazoResult) {
|
140 |
+
return false;
|
141 |
+
}
|
142 |
+
|
143 |
if(!$request = $request->Servicos) {
|
144 |
+
return false;
|
145 |
}
|
146 |
+
|
147 |
if(!$request = $request->cServico) {
|
148 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
+
|
151 |
+
$result = array();
|
152 |
+
|
153 |
+
if(is_array($request)) {
|
154 |
+
foreach($request as $methodData) {
|
155 |
+
$result[] = $this->_convertWebserviceValues($methodData);
|
156 |
+
}
|
157 |
+
} elseif(isset($request->Codigo)) {
|
158 |
+
$result[] = $this->_convertWebserviceValues($request);
|
159 |
+
} else {
|
160 |
+
throw new Exception(Mage::helper('correios')->__('Cannot be possible to estimate shipping from Correios.'));
|
161 |
+
}
|
162 |
+
|
163 |
return $result;
|
164 |
}
|
165 |
+
|
166 |
/**
|
167 |
* Gets the helper module's main
|
168 |
+
*
|
169 |
* @return Storm_Correios_Helper_Data
|
170 |
*/
|
171 |
protected function _getHelper()
|
172 |
{
|
173 |
return Mage::helper('correios');
|
174 |
}
|
175 |
+
|
176 |
/**
|
177 |
* Converts the data returned from webservice to the object
|
178 |
* Varien_Object using the parameter names in English
|
179 |
+
*
|
180 |
* @param stdClass $data
|
181 |
* @return Varien_Object
|
182 |
*/
|
183 |
private function _convertWebserviceValues(stdClass $data)
|
184 |
{
|
185 |
$result = new Varien_Object();
|
186 |
+
$result->setCode($data->Codigo);
|
187 |
+
|
188 |
if($data->Erro != 0) {
|
189 |
$result->setError($data->Erro)
|
190 |
->setErrorMessage($data->MsgErro);
|
191 |
+
|
192 |
return $result;
|
193 |
}
|
194 |
+
|
195 |
$result->setPrice($this->_getHelper()->convertToFloat($data->Valor))
|
196 |
->setDeliveryTime($data->PrazoEntrega + intval($this->_getHelper()->getConfigData('add_delivery_time')))
|
197 |
->setHomeDelivery($data->EntregaDomiciliar == 'S' ? true : false)
|
app/locale/pt_BR/Storm_Correios.csv
CHANGED
@@ -43,4 +43,5 @@
|
|
43 |
"You must to install PHP Soap extension to use shipping method Correios.","Você deve instalar a extensão Soap do PHP para usar o método de entrega dos Correios."
|
44 |
"Show delivery time","Mostrar o prazo de entrega"
|
45 |
"Use receipt warning","Usar aviso de recebimento"
|
46 |
-
"Use own hands","Utilizar mão própria"
|
|
43 |
"You must to install PHP Soap extension to use shipping method Correios.","Você deve instalar a extensão Soap do PHP para usar o método de entrega dos Correios."
|
44 |
"Show delivery time","Mostrar o prazo de entrega"
|
45 |
"Use receipt warning","Usar aviso de recebimento"
|
46 |
+
"Use own hands","Utilizar mão própria"
|
47 |
+
"Cannot be possible to estimate shipping from Correios.","Não foi possível estimar o frete dos Correios."
|
package.xml
CHANGED
@@ -1,30 +1,29 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>correios</name>
|
4 |
-
<version>1.3.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL 3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Módulo de cálculo de frete e prazo de entrega dos Correios com Pac, Sedex, Sedex 10, Sedex Hoje e e-Sedex.</summary>
|
10 |
-
<description>Módulo para efetuar cálculo de frete e prazo de entrega dos Correios
|
11 |
-
As seguintes funções estão disponíves
|
12 |
-
|
13 |
-
*
|
14 |
-
*
|
15 |
-
*
|
16 |
-
*
|
17 |
-
* Possibilidade de adicionar
|
18 |
-
*
|
19 |
-
|
20 |
-
|
21 |
-
<hr />
|
22 |
This module is available only to Brazil.</description>
|
23 |
-
<notes
|
24 |
<authors><author><name>Willian</name><user>willsouza</user><email>williancordeirodesouza@gmail.com</email></author></authors>
|
25 |
-
<date>2013-
|
26 |
-
<time>00:
|
27 |
-
<contents><target name="magecommunity"><dir name="Storm"><dir name="Correios"><dir name="Helper"><file name="Data.php" hash="c0344a3cccf20787f115b24cacef68b7"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="3e2d7ae7abb9dc2131f2a7868fd89d87"/></dir><dir name="Carrier"><dir name="Package"><file name="Dimension.php" hash="88d12d19a36e753c94f30c08431e9c45"/></dir><dir name="Shipping"><file name="Tracking.php" hash="97c09a03c9bc77ded9e01099887ecb67"/></dir><file name="Shipping.php" hash="e8d22369e1d5e185585684774711776b"/><file name="Webservice.php" hash="
|
28 |
<compatible/>
|
29 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
30 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>correios</name>
|
4 |
+
<version>1.3.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL 3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Módulo de cálculo de frete e prazo de entrega dos Correios com Pac, Sedex, Sedex 10, Sedex Hoje e e-Sedex.</summary>
|
10 |
+
<description>Módulo para efetuar cálculo de frete e prazo de entrega dos Correios.
|
11 |
+
As seguintes funções estão disponíves:
|
12 |
+

|
13 |
+
* Entrega com Sedex, Sedex a cobrar, Sedex 10, Sedex hoje, Pac, e-Sedex, e-Sedex prioritário e e-Sedex express.
|
14 |
+
* Configurações para comerciantes com contrato com os Correios com preço diferenciado.
|
15 |
+
* Rastreador de objeto em tempo real.
|
16 |
+
* Escolha do método de frete grátis inteligente ( segue regras de promoção ).
|
17 |
+
* Possibilidade de adicionar dias ao prazo de entrega.
|
18 |
+
* Possibilidade de adicionar taxa de manuseio fixa ou percentual.
|
19 |
+
* Configuração e instalação fácil e intuítiva.
|
20 |
+

|
|
|
21 |
This module is available only to Brazil.</description>
|
22 |
+
<notes>Correção de bug ao selecionar apenas um dos métodos de entrega.</notes>
|
23 |
<authors><author><name>Willian</name><user>willsouza</user><email>williancordeirodesouza@gmail.com</email></author></authors>
|
24 |
+
<date>2013-12-05</date>
|
25 |
+
<time>00:27:17</time>
|
26 |
+
<contents><target name="magecommunity"><dir name="Storm"><dir name="Correios"><dir name="Helper"><file name="Data.php" hash="c0344a3cccf20787f115b24cacef68b7"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Observer.php" hash="3e2d7ae7abb9dc2131f2a7868fd89d87"/></dir><dir name="Carrier"><dir name="Package"><file name="Dimension.php" hash="88d12d19a36e753c94f30c08431e9c45"/></dir><dir name="Shipping"><file name="Tracking.php" hash="97c09a03c9bc77ded9e01099887ecb67"/></dir><file name="Shipping.php" hash="e8d22369e1d5e185585684774711776b"/><file name="Webservice.php" hash="e1f0bb7b3d53acbd10c2c550b79fe5a3"/></dir><dir name="Catalog"><dir name="Resource"><file name="Setup.php" hash="833a10b8bc912d3df9818f3b0f86d442"/></dir></dir><dir name="Source"><file name="FreeMethods.php" hash="67646bf270c42fa6fa8b79de336236b3"/><file name="Methods.php" hash="d9118016fe15471f813682385c95a93b"/></dir></dir><dir name="etc"><file name="config.xml" hash="2ba451fdb748cdaf09ecf19c669b0379"/><file name="system.xml" hash="ae02d64e5ad304a3dc256ccdd490d646"/></dir><dir name="sql"><dir name="correios_setup"><file name="mysql4-install-0.1.0.php" hash="dca339c0e46e4b9d116bc1eea9d09930"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="pt_BR"><file name="Storm_Correios.csv" hash="53c7b3305663dea7aff6566acde6b4b4"/></dir></target><target name="mageetc"><dir name="modules"><file name="Storm_Correios.xml" hash="93aa3a9938657131b77fa2a2e60abd71"/></dir></target></contents>
|
27 |
<compatible/>
|
28 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
29 |
</package>
|