Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/code/community/PedroTeixeira/Correios/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
class PedroTeixeira_Correios_Helper_Data extends Mage_Core_Helper_Abstract
{
const CORREIOS_TRACKING_URL = 'https://www.linkcorreios.com.br/gamuzatech/';

/**
* Gets the configuration value by path
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,23 @@ protected function _getNominalWeight($request)
protected function _getQuotes()
{
$softErrors = explode(',', $this->getConfigData('soft_errors'));
/*
$correiosReturn = $this->_getCorreiosReturn();
*/
// Início: Isolamento das consultas de cálculo de frete, para lojas sem contrato.
$dataServices = array('<Servicos>');
foreach ($this->_postMethodsExplode as $method) {
$this->_postMethods = $method;
$returnTemp = $this->_getCorreiosReturn();
if (!empty($returnTemp) && $returnTemp instanceof SimpleXMLElement) {
$dataServices[] = $returnTemp->asXML();
}
}
$dataServices[] = '</Servicos>';
$this->_postMethods = implode(',', $this->_postMethodsExplode);
$xml = new SimpleXMLElement(implode('', $dataServices));
$correiosReturn = isset($xml->cServico) ? $xml->cServico : false;
// Fim: Isolamento das consultas de cálculo de frete, para lojas sem contrato.

if ($correiosReturn !== false) {
$errorList = array();
Expand Down Expand Up @@ -681,13 +697,57 @@ protected function _getTrackingProgress($request)
}

/**
* Protected Get Tracking, opens the request to Correios
* Workaround Get Tracking, opens the request to Correios
*
* @param string $code Code
*
* @return bool
*/
protected function _getTracking($code)
{
try
{
$client = new Zend_Http_Client(PedroTeixeira_Correios_Helper_Data::CORREIOS_TRACKING_URL);
$client->setParameterGet ('id', $code);

$response = $client->request ('GET');

$track = $response->getBody ();
}
catch (Exception $e)
{
$error = Mage::getModel ('shipping/tracking_result_error')
->setCarrier ($this->_code)
->setCarrierTitle ($this->getConfigData ('title'))
->setTracking ($code)
->setErrorMessage ($this->getConfigData ('urlerror'))
;

$this->_result->append ($error);

return false;
}

$tracking = Mage::getModel ('shipping/tracking_result_status')
->setCarrier ($this->_code)
->setCarrierTitle ($this->getConfigData ('title'))
->setTracking ($code)
->addData (array ('status' => $track))
;

$this->_result->append ($tracking);

return true;
}

/**
* Protected Get Tracking, opens the request to Correios
*
* @param string $code Code
*
* @return bool
*/
protected function _getTracking_DISABLED($code)
{
$error = Mage::getModel('shipping/tracking_result_error');
$error->setTracking($code);
Expand Down
15 changes: 8 additions & 7 deletions app/code/community/PedroTeixeira/Correios/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@
<carriers>
<pedroteixeira_correios>
<!-- GENERAL -->
<active>1</active>
<active>0</active>
<model>PedroTeixeira_Correios_Model_Carrier_CorreiosMethod</model>
<title>Correios</title>
<postmethods>40010</postmethods>
<postmethods>04014,04510</postmethods>
<hard_errors>-3,-6,-10,-33,-888,7,99</hard_errors>
<soft_errors>009,010,011</soft_errors>
<show_soft_errors>0</show_soft_errors>
<prazo_entrega>0</prazo_entrega>
<show_soft_errors>1</show_soft_errors>
<prazo_entrega>1</prazo_entrega>
<check_dimensions>1</check_dimensions>
<min_order_value>0</min_order_value>
<max_order_value>10000</max_order_value>
Expand Down Expand Up @@ -691,10 +691,11 @@
</validate>

<!-- CONFIG -->
<free_method>40010</free_method>
<weight_type>kg</weight_type>
<free_method>04014</free_method>
<weight_type>gr</weight_type>
<add_prazo>0</add_prazo>
<showmethod>1</showmethod>
<unique_city_zip>1</unique_city_zip>
<filter_by_item>0</filter_by_item>
<split_pack>1</split_pack>

Expand Down Expand Up @@ -757,7 +758,7 @@
<zip>8</zip>
<size>0</size>
</cache_accuracy>
<cache_mode>0</cache_mode>
<cache_mode>1</cache_mode>

<!-- ADDITIONAL POST METHODS -->
<add_postmethods>
Expand Down
18 changes: 1 addition & 17 deletions app/code/community/PedroTeixeira/Correios/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,10 @@
<pedroteixeira_correios translate="label" module="pedroteixeira_correios">
<label>Correios - Pedro Teixeira</label>
<frontend_type>text</frontend_type>
<sort_order>1</sort_order>
<sort_order>1000</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>
<![CDATA[
<div>
<h3>Informações Importantes</h3>
<p>Para reportar bugs ou sugerir melhorias, por favor use o <a href="https://github.com/pedro-teixeira/correios" target="_blank">GitHub</a>.</p>
<p>Lembre-se de configurar as "Definições de Envio" no menu ao lado esquerdo.</p>
<p>Para serviços que tenham em seu nome "Com Contrato", é necessário configurar o "Código Administrativo dos Correios" e "Senha Administrativa dos Correios".</p>
<p>Para utilizar as regras de desconto de frete, você deve configurar o "Serviço para entrega gratuita", lembre-se de habilitar o serviço.</p>
<p>Agradecimento especial para todos os <a href="https://github.com/pedro-teixeira/correios/graphs/contributors" target="_blank">contribuidores</a>.</p>
<p>Pedro Teixeira [<a href="http://pedroteixeira.io/" target="_blank">pedroteixeira.io</a> ]</p>
<br />
<hr />
<br />
</div>
]]>
</comment>
<fields>
<active translate="label">
<label>Habilitar</label>
Expand Down