diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..af063e3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,18 @@ +# 4.0.0 +--- + +### Bugfix + +- Problema do getBody() +- Problema com o ereg() +- Problema de "The locale 'root' is no known locale" corrigido +- Problema no tracking + +### Feature + +- Nova forma de passar o volume para os Correios +- Sedex a Cobrar +- Instalação automática dos atributos de volume +- Log de erros +- Configuração do formato de peso +- Novas mensagens de erro \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..42259f4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2010 Pedro Teixeira + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/app/code/community/PedroTeixeira/Correios/Helper/Data.php b/app/code/community/PedroTeixeira/Correios/Helper/Data.php new file mode 100755 index 0000000..43ffde5 --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/Helper/Data.php @@ -0,0 +1,17 @@ + + * @license http://opensource.org/licenses/MIT + */ + +class PedroTeixeira_Correios_Helper_Data extends Mage_Core_Helper_Abstract +{ + +} \ No newline at end of file diff --git a/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php new file mode 100755 index 0000000..ccd5480 --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/Model/Carrier/CorreiosMethod.php @@ -0,0 +1,608 @@ + + * @license http://opensource.org/licenses/MIT + */ + +/** + * PedroTeixeira_Correios_Model_Carrier_CorreioMethod + * + * @category PedroTeixeira + * @package PedroTeixeira_Correios + * @author Pedro Teixeira + */ + +class ParametersLocaweb +{ +} + +class PedroTeixeira_Correios_Model_Carrier_CorreiosMethod + extends Mage_Shipping_Model_Carrier_Abstract + implements Mage_Shipping_Model_Carrier_Interface +{ + + /** + * _code property + * + * @var string + */ + protected $_code = 'pedroteixeira_correios'; + + /** + * _result property + * + * @var Mage_Shipping_Model_Rate_Result / Mage_Shipping_Model_Tracking_Result + */ + protected $_result = null; + + /** + * Check if current carrier offer support to tracking + * + * @return boolean true + */ + public function isTrackingAvailable() + { + return true; + } + + /** + * Collect Rates + * + * @param Mage_Shipping_Model_Rate_Request $request + * + * @return Mage_Shipping_Model_Rate_Result + */ + public function collectRates(Mage_Shipping_Model_Rate_Request $request) + { + if (!$this->getConfigFlag('active')) { + //Disabled + Mage::log('PedroTeixeira_Correios: Disabled'); + return false; + } + + + $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore()); + $destCountry = $request->getDestCountryId(); + if ($origCountry != "BR" || $destCountry != "BR") { + //Out of delivery area + Mage::log('PedroTeixeira_Correios: Out of delivery area'); + return false; + } + + + + $result = Mage::getModel('shipping/rate_result'); + $error = Mage::getModel('shipping/rate_result_error'); + + $error->setCarrier($this->_code); + $error->setCarrierTitle($this->getConfigData('title')); + + + $packagevalue = $request->getBaseCurrency()->convert( + $request->getPackageValue(), + $request->getPackageCurrency() + ); + $minorderval = $this->getConfigData('min_order_value'); + $maxorderval = $this->getConfigData('max_order_value'); + if ($packagevalue <= $minorderval || $packagevalue >= $maxorderval) { + //Value limits + Mage::log('PedroTeixeira_Correios: Value limits'); + $error->setErrorMessage($this->getConfigData('valueerror')); + $result->append($error); + return $result; + } + + $frompcode = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()); + $topcode = $request->getDestPostcode(); + + //Fix Zip Code + $frompcode = str_replace('-', '', trim($frompcode)); + $topcode = str_replace('-', '', trim($topcode)); + + if (!preg_match("/^([0-9]{8})$/", $topcode)) { + //Invalid Zip Code + Mage::log('PedroTeixeira_Correios: Invalid Zip Code'); + $error->setErrorMessage($this->getConfigData('zipcodeerror')); + $result->append($error); + Mage::helper('customer')->__('Invalid ZIP CODE'); + return $result; + } + + + $sweight = $request->getPackageWeight(); + $weightCompare = $this->getConfigData('maxweight'); + + if ($this->getConfigData('weight_type') == 'gr') { + $sweight = number_format($sweight / 1000, 2, '.', ''); + $weightCompare = number_format($weightCompare / 1000, 2, '.', ''); + } + + + if ($sweight > $weightCompare) { + //Weight exceeded limit + Mage::log('PedroTeixeira_Correios: Weight exceeded limit'); + $error->setErrorMessage($this->getConfigData('maxweighterror')); + $result->append($error); + return $result; + } + + + if ($sweight == 0) { + //Weight zero + Mage::log('PedroTeixeira_Correios: Weight zero'); + $error->setErrorMessage($this->getConfigData('weightzeroerror')); + $result->append($error); + return $result; + } + + + //Create the volume of the cart + + $pesoCubicoTotal = 0; + $volumeTotal = 0; + + $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems(); + + foreach ($items as $item) { + + $while = 0; + $_product = $item->getProduct(); + + if ($_product->getData('volume_altura') == '' || (int) $_product->getData('volume_altura') == 0) { + $itemAltura = $this->getConfigData('altura_padrao'); + } else { + $itemAltura = $_product->getData('volume_altura'); + } + + if ($_product->getData('volume_largura') == '' || (int) $_product->getData('volume_largura') == 0) { + $itemLargura = $this->getConfigData('largura_padrao'); + } else { + $itemLargura = $_product->getData('volume_largura'); + } + + if ($_product->getData('volume_comprimento') == '' || (int) $_product->getData('volume_comprimento') == 0) { + $itemComprimento = $this->getConfigData('comprimento_padrao'); + } else { + $itemComprimento = $_product->getData('volume_comprimento'); + } + + while ($while < $item->getQty()) { + $itemPesoCubico = ($itemAltura * $itemLargura * $itemComprimento) / 4800; + $pesoCubicoTotal = $pesoCubicoTotal + $itemPesoCubico; + $volumeTotal = $volumeTotal + ($itemPesoCubico * 4800); + + $while++; + } + } + + if ($pesoCubicoTotal > $sweight) { + $mediaMedidas = round(pow((int) $volumeTotal, (1 / 3))); + $volumeComprimento = (($mediaMedidas < 16) ? 16 : $mediaMedidas); + $volumeAltura = (($mediaMedidas < 2) ? 2 : $mediaMedidas); + $volumeLargura = (($mediaMedidas < 11) ? 11 : $mediaMedidas); + } else { + $volumeComprimento = 16; + $volumeAltura = 2; + $volumeLargura = 11; + } + + //Define post method + $shipping_methods = array(); + + $postmethods = explode(",", $this->getConfigData('postmethods')); + + foreach ($postmethods as $methods) { + + switch ($methods) { + case 0: + $shipping_methods["40010"] = array("Sedex", "3"); + break; + case 1: + $shipping_methods["40096"] = array("Sedex", "3"); + break; + case 2: + $shipping_methods["81019"] = array("E-Sedex", "3"); + break; + case 3: + $shipping_methods["41025"] = array("PAC", "3"); + break; + case 4: + $shipping_methods["41106"] = array("PAC", "3"); + break; + case 5: + $shipping_methods["41068"] = array("PAC", "3"); + break; + case 6: + $shipping_methods["40215"] = array("Sedex 10", "1"); + break; + case 7: + $shipping_methods["40290"] = array("Sedex HOJE", "1"); + break; + case 8: + $shipping_methods["40045"] = array("Sedex a Cobrar", "5"); + break; + } + } + + foreach ($shipping_methods as $shipping_method => $shipping_values) { + + //Define URL method + switch ($this->getConfigData('urlmethod')) { + + case 1: + + $correiosWSLocaWeb = "http://comercio.locaweb.com.br/correios/frete.asmx?WSDL"; + + $soap = @new SoapClient($correiosWSLocaWeb, array( + 'trace' => true, + 'exceptions' => true, + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, + 'connection_timeout' => 1000 + )); + + // Postagem dos parâmetros + $parms = new ParametersLocaweb(); + $parms->cepOrigem = utf8_encode($frompcode); + $parms->cepDestino = utf8_encode($topcode); + $parms->peso = utf8_encode(str_replace(".", ",", $sweight)); + $parms->volume = utf8_encode($volumeTotal); + $parms->codigo = utf8_encode($shipping_method); + + // Resgata o valor calculado + $resposta = $soap->Correios($parms); + + $shippingPrice = floatval(str_replace(",", ".", $resposta->CorreiosResult)); + + break; + + case 0: + + $filename = "http://shopping.correios.com.br/wbm/shopping/script/CalcPrecoPrazo.aspx"; + + try { + $client = new Zend_Http_Client($filename); + + $client->setParameterGet('StrRetorno', 'xml'); + $client->setParameterGet('nCdServico', $shipping_method); + $client->setParameterGet('nVlPeso', $sweight); + $client->setParameterGet('sCepOrigem', $frompcode); + $client->setParameterGet('sCepDestino', $topcode); + $client->setParameterGet('nCdFormato', 1); + $client->setParameterGet('nVlComprimento', $volumeComprimento); + $client->setParameterGet('nVlAltura', $volumeAltura); + $client->setParameterGet('nVlLargura', $volumeLargura); + if ($this->getConfigData('mao_propria')) { + $client->setParameterGet('sCdMaoPropria', 'S'); + } else { + $client->setParameterGet('sCdMaoPropria', 'N'); + } + + if ($this->getConfigData('aviso_recebimento')) { + $client->setParameterGet('sCdAvisoRecebimento', 'S'); + } else { + $client->setParameterGet('sCdAvisoRecebimento', 'N'); + } + + if ($this->getConfigData('valor_declarado') || $shipping_method == 40045) { + $client->setParameterGet('nVlValorDeclarado', number_format($packagevalue, 2, ',', '.')); + } else { + $client->setParameterGet('nVlValorDeclarado', 0); + } + + + + if ($shipping_method == 40096 || $shipping_method == 81019 || $shipping_method == 41068) { + if ($this->getConfigData('cod_admin') == '' || $this->getConfigData('senha_admin') == '') { + // Need correios admin data + Mage::log('PedroTeixeira_Correios: Need correios admin data'); + $error->setErrorMessage($this->getConfigData('coderror')); + $result->append($error); + return $result; + } else { + $client->setParameterGet('nCdEmpresa', $this->getConfigData('cod_admin')); + $client->setParameterGet('sDsSenha', $this->getConfigData('senha_admin')); + } + } + + $content = $client->request(); + $conteudo = $content->getBody(); + + if (!stristr($conteudo, "setCarrier($this->_code); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setMethod($shipping_method); + $error->setErrorMessage($this->getConfigData('urlerror')); + $result->append($error); + $shippingPrice = 0; + + continue; + }; + + preg_match_all("/(.+)<\/Codigo>/", $conteudo, $xml_servico); + preg_match_all("/(.+)<\/Valor>/", $conteudo, $preco_postal); + preg_match_all("/(.+)<\/PrazoEntrega>/", $conteudo, $prazo_postal); + preg_match_all("/(.+)<\/Erro>/", $conteudo, $err_id); + $err_id = str_replace('-', '', $err_id[1][0]); + $err_id = (int) $err_id; + preg_match_all("/(.+)<\/MsgErro>/", $conteudo, $err_msg); + + + $correiosReturn = array( + "prazo" => $prazo_postal[1][0] + ); + + if (trim($err_id) == "0") { + $shippingPrice = floatval(str_replace(",", ".", $preco_postal[1][0])); + } else { + + $ignorar = explode(',', $this->getConfigData('ignorar_erro')); + $ignorar = array_flip($ignorar); + if (!array_key_exists($err_id, $ignorar)) { + //Error + $error = Mage::getModel('shipping/rate_result_error'); + $error->setCarrier($this->_code); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setMethod($shipping_method); + + // Correios Error + Mage::log('PedroTeixeira_Correios: Correios Error'); + $error->setErrorMessage( + sprintf( + $this->getConfigData('correioserror'), + $shipping_values[0], + $err_msg[1][0], + $err_id + ) + ); + $result->append($error); + $shippingPrice = 0; + } else { + $shippingPrice = 0; + } + } + + + break; + default: + //URL method undefined + Mage::log('PedroTeixeira_Correios: URL method undefined'); + $error->setErrorMessage($this->getConfigData('urlerror')); + $result->append($error); + return $result; + } + + if ($shippingPrice <= 0) { + continue; + } + + $method = Mage::getModel('shipping/rate_result_method'); + + $method->setCarrier($this->_code); + $method->setCarrierTitle($this->getConfigData('title')); + + $method->setMethod($shipping_method); + + if ($this->getConfigFlag('prazo_entrega')) { + + if (isset($correiosReturn)) { + if ($correiosReturn['prazo'] > 0) { + $method->setMethodTitle( + sprintf( + $this->getConfigData('msgprazo'), + $shipping_values[0], + (int) $correiosReturn['prazo'] + $this->getConfigData('add_prazo') + ) + ); + } else { + $method->setMethodTitle( + sprintf( + $this->getConfigData('msgprazo'), + $shipping_values[0], + $shipping_values[1] + $this->getConfigData('add_prazo') + ) + ); + } + } else { + $method->setMethodTitle( + sprintf( + $this->getConfigData('msgprazo'), + $shipping_values[0], + $shipping_values[1] + $this->getConfigData('add_prazo') + ) + ); + } + } else { + $method->setMethodTitle($shipping_values[0]); + } + + $method->setPrice($shippingPrice + $this->getConfigData('handling_fee')); + + $method->setCost($shippingPrice); + + $result->append($method); + + $shippingPrice = null; + } + + $this->_result = $result; + + $this->_updateFreeMethodQuote($request); + + return $this->_result; + } + + /** + * Get Tracking Info + * + * @param mixed $tracking + * + * @return mixed + */ + public function getTrackingInfo($tracking) + { + $result = $this->getTracking($tracking); + if ($result instanceof Mage_Shipping_Model_Tracking_Result) { + if ($trackings = $result->getAllTrackings()) { + return $trackings[0]; + } + } elseif (is_string($result) && !empty($result)) { + return $result; + } + + return false; + } + + /** + * Get Tracking + * + * @param array $trackings + * + * @return Mage_Shipping_Model_Tracking_Result + */ + public function getTracking($trackings) + { + $this->_result = Mage::getModel('shipping/tracking_result'); + foreach ((array) $trackings as $code) { + $this->_getTracking($code); + } + return $this->_result; + } + + /** + * Protected Get Tracking, opens the request to Correios + * + * @param string $code + * + * @return boolean + */ + protected function _getTracking($code) + { + $error = Mage::getModel('shipping/tracking_result_error'); + $error->setTracking($code); + $error->setCarrier($this->_code); + $error->setCarrierTitle($this->getConfigData('title')); + $error->setErrorMessage($this->getConfigData('urlerror')); + + $url = 'http://websro.correios.com.br/sro_bin/txect01$.QueryList'; + $url .= '?P_LINGUA=001&P_TIPO=001&P_COD_UNI=' . $code; + try { + $client = new Zend_Http_Client(); + $client->setUri($url); + $content = $client->request(); + $body = $content->getBody(); + } catch (Exception $e) { + $this->_result->append($error); + return false; + } + + if (!preg_match('#]+)>(.*?)
#is', $body, $matches)) { + $this->_result->append($error); + return false; + } + $table = $matches[2]; + + if (!preg_match_all('/(.*)<\/tr>/i', $table, $columns, PREG_SET_ORDER)) { + $this->_result->append($error); + return false; + } + + $progress = array(); + for ($i = 0; $i < count($columns); $i++) { + $column = $columns[$i][1]; + + $description = ''; + $found = false; + if (preg_match('/(.*)<\/td>(.*)<\/td>(.*)<\/font><\/td>/i', + $column, + $matches + ) + ) { + if (preg_match('/(.*)<\/td>/i', $columns[$i + 1][1], $matchesDescription)) { + $description = str_replace(' ', '', $matchesDescription[1]); + } + + $found = true; + } elseif (preg_match( + '/(.*)<\/td>(.*)<\/td>(.*)<\/font><\/td>/i', + $column, + $matches + ) + ) { + $found = true; + } + + if ($found) { + $datetime = split(' ', $matches[1]); + + $locale = new Zend_Locale('pt_BR'); + $date = ''; + $date = new Zend_Date($datetime[0], 'dd/MM/YYYY', $locale); + + $track = array( + 'deliverydate' => $date->toString('YYYY-MM-dd'), + 'deliverytime' => $datetime[1] . ':00', + 'deliverylocation' => htmlentities($matches[2]), + 'status' => htmlentities($matches[3]), + 'activity' => htmlentities($matches[3]) + ); + + if ($description !== '') { + $track['activity'] = $matches[3] . ' - ' . htmlentities($description); + } + + $progress[] = $track; + } + } + + if (!empty($progress)) { + $track = $progress[0]; + $track['progressdetail'] = $progress; + + $tracking = Mage::getModel('shipping/tracking_result_status'); + $tracking->setTracking($code); + $tracking->setCarrier('correios'); + $tracking->setCarrierTitle($this->getConfigData('title')); + $tracking->addData($track); + + $this->_result->append($tracking); + return true; + } else { + $this->_result->append($error); + return false; + } + } + + /** + * Returns the allowed carrier methods + * + * @return array + */ + public function getAllowedMethods() + { + return array($this->_code => $this->getConfigData('title')); + } + + /** + * Define ZIP Code as required + * + * @return boolean + */ + public function isZipCodeRequired() + { + return true; + } +} diff --git a/app/code/community/PedroTeixeira/Correios/Model/Source/FreeMethods.php b/app/code/community/PedroTeixeira/Correios/Model/Source/FreeMethods.php new file mode 100755 index 0000000..0bfac51 --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/Model/Source/FreeMethods.php @@ -0,0 +1,34 @@ + + * @license http://opensource.org/licenses/MIT + */ + +class PedroTeixeira_Correios_Model_Source_FreeMethods +{ + + public function toOptionArray() + { + return array( + array('value' => 40010, 'label' => Mage::helper('adminhtml')->__('Sedex Sem Contrato (Correios)')), + array('value' => 40096, 'label' => Mage::helper('adminhtml')->__('Sedex Com Contrato (Correios/Locaweb)')), + array( + 'value' => 81019, + 'label' => Mage::helper('adminhtml')->__('E-Sedex Com Contrato (Correios/Locaweb)') + ), + array('value' => 41025, 'label' => Mage::helper('adminhtml')->__('PAC Normal (Locaweb)')), + array('value' => 41106, 'label' => Mage::helper('adminhtml')->__('PAC Sem Contrato (Correios)')), + array('value' => 41068, 'label' => Mage::helper('adminhtml')->__('PAC Com Contrato (Correios/Locaweb)')), + array('value' => 40215, 'label' => Mage::helper('adminhtml')->__('Sedex 10 (Correios)')), + array('value' => 40290, 'label' => Mage::helper('adminhtml')->__('Sedex HOJE (Correios)')), + array('value' => 40045, 'label' => Mage::helper('adminhtml')->__('Sedex a Cobrar (Correios)')), + ); + } +} \ No newline at end of file diff --git a/app/code/community/PedroTeixeira/Correios/Model/Source/PostMethods.php b/app/code/community/PedroTeixeira/Correios/Model/Source/PostMethods.php new file mode 100755 index 0000000..93eb247 --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/Model/Source/PostMethods.php @@ -0,0 +1,31 @@ + + * @license http://opensource.org/licenses/MIT + */ + +class PedroTeixeira_Correios_Model_Source_PostMethods +{ + + public function toOptionArray() + { + return array( + array('value' => 0, 'label' => Mage::helper('adminhtml')->__('Sedex Sem Contrato (Correios)')), + array('value' => 1, 'label' => Mage::helper('adminhtml')->__('Sedex Com Contrato (Correios/Locaweb)')), + array('value' => 2, 'label' => Mage::helper('adminhtml')->__('E-Sedex Com Contrato (Correios/Locaweb)')), + array('value' => 3, 'label' => Mage::helper('adminhtml')->__('PAC Normal (Locaweb)')), + array('value' => 4, 'label' => Mage::helper('adminhtml')->__('PAC Sem Contrato (Correios)')), + array('value' => 5, 'label' => Mage::helper('adminhtml')->__('PAC Com Contrato (Correios/Locaweb)')), + array('value' => 6, 'label' => Mage::helper('adminhtml')->__('Sedex 10 (Correios)')), + array('value' => 7, 'label' => Mage::helper('adminhtml')->__('Sedex HOJE (Correios)')), + array('value' => 8, 'label' => Mage::helper('adminhtml')->__('Sedex a Cobrar (Correios)')), + ); + } +} \ No newline at end of file diff --git a/app/code/community/PedroTeixeira/Correios/Model/Source/UrlMethods.php b/app/code/community/PedroTeixeira/Correios/Model/Source/UrlMethods.php new file mode 100755 index 0000000..3acbe98 --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/Model/Source/UrlMethods.php @@ -0,0 +1,24 @@ + + * @license http://opensource.org/licenses/MIT + */ + +class PedroTeixeira_Correios_Model_Source_UrlMethods +{ + + public function toOptionArray() + { + return array( + array('value' => 1, 'label' => Mage::helper('adminhtml')->__('Locaweb')), + array('value' => 0, 'label' => Mage::helper('adminhtml')->__('Correios')), + ); + } +} \ No newline at end of file diff --git a/app/code/community/PedroTeixeira/Correios/Model/Source/WeightType.php b/app/code/community/PedroTeixeira/Correios/Model/Source/WeightType.php new file mode 100755 index 0000000..4e8e751 --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/Model/Source/WeightType.php @@ -0,0 +1,24 @@ + + * @license http://opensource.org/licenses/MIT + */ + +class PedroTeixeira_Correios_Model_Source_WeightType +{ + + public function toOptionArray() + { + return array( + array('value' => 'gr', 'label' => Mage::helper('adminhtml')->__('Gramas')), + array('value' => 'kg', 'label' => Mage::helper('adminhtml')->__('Kilos')), + ); + } +} \ No newline at end of file diff --git a/app/code/community/PedroTeixeira/Correios/etc/config.xml b/app/code/community/PedroTeixeira/Correios/etc/config.xml new file mode 100755 index 0000000..b86cbeb --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/etc/config.xml @@ -0,0 +1,107 @@ + + + + + + 4.0.0 + + + + + + + + + + + + + + + + + + + + PedroTeixeira_Correios_Model + + + + + + PedroTeixeira_Correios + + + directory_setup + + + + + + PedroTeixeira_Correios_Helper + + + + + + + PedroTeixeira_Correios_Model_Carrier_CorreiosMethod + + + + + + + + + + 1 + PedroTeixeira_Correios_Model_Carrier_CorreiosMethod + Correios + 0 + 0 + 0 + 1,2,5,6,7,10,36,37,38,99 + 2 + 16 + 11 + 0 + 0 + 0 + 500 + 0 + kg + 30 + 0 + 0 + %s - Em média %d dia(s) + 40010 + %s - Houve um erro inesperado, por favor entre em contato. %s (Cod. %d) + Valor de compra a cima do permitido pelos Correios. Por favor entre em contato conosco. + + Por favor, corrija o CEP digitado, ele não está correto. + Peso dos produtos a cima do permitido pelos Correios. Por favor entre em contato + conosco. + + Lojista: O peso do produto deverá ser maior que zero. Se você está usando a media de + peso como gramas, o peso mínimo é de 10 gramas. + + Esse método de envio está fora do ar. Por favor entre em contato conosco. + Lojista: Para calcular esse serviço você precisa ter contrato com os Correios. + 0 + + + + \ No newline at end of file diff --git a/app/code/community/PedroTeixeira/Correios/etc/system.xml b/app/code/community/PedroTeixeira/Correios/etc/system.xml new file mode 100755 index 0000000..e30a4d2 --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/etc/system.xml @@ -0,0 +1,319 @@ + + + + + + + + + text + 1 + 1 + 1 + 1 + + +
+ Informações Importantes

+ Você pode tirar dúvidas ou sugerir melhorias do módulo através do site www.pteixeira.com.br.

+ Na versão 4.0.0 o módulo de cálculo de frete conta com instalação automática dos atributos de volume, SEDEX a Cobrar, opção de configurar o formato do peso de seus produtos, + correção do problema de getBody(), correção do problema de ereg(), nova forma de passar o volume para cálculo do PAC, log de erros e outras funcionalidades.

+ Para um bom funcionamento do módulo, é necessário que você configure os serviços que deseja disponibilizar em sua loja e escolher a fonte de cálculo de acordo com os serviços habilitados. + Por exemplo, se você habilitar "Sedex Com Contrato (Correios)" lembre-se de configurar a fonte de cálculo como Correios, já se habilitar "PAC Normal (Locaweb)" lembre-se de configurar a fonte como "Locaweb".

+ Lembre-se de configurar as "Definições de Envio" no menu ao lado esquerdo.

+ Para serviços que tenham em seu nome "Com Contrato", é necessário configurar o "Código Administrativo dos Correios" e "Senha Administrativa dos Correios".

+ A lista completa de códigos de erros está disponibilizada no site do desenvolvedor.

+ Importante: Para utilização da função de tracking é necessário corrigir alguns erros do próprio Magento, veja mais informações no site do desenvolvedor. +




+ + ]]> +
+ + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + <label>Nome do Meio de Entrega</label> + <frontend_type>text</frontend_type> + <sort_order>15</sort_order> + <show_in_default>1</show_in_default> + <show_in_website>1</show_in_website> + <show_in_store>1</show_in_store> + + + + multiselect + PedroTeixeira_Correios_Model_Source_PostMethods + 20 + 1 + 1 + 1 + Serviços que estarão disponíveis, lembre-se de usar os serviços correspondentes a + fonte configurada. + + + + + select + PedroTeixeira_Correios_Model_Source_UrlMethods + 30 + 1 + 1 + 1 + Ative apenas os serviços relativos a fonte. + + + + select + PedroTeixeira_Correios_Model_Source_WeightType + 30 + 1 + 1 + 1 + Formato do peso dos produtos. + + + + select + adminhtml/system_config_source_yesno + 40 + 1 + 1 + 1 + + + + text + 61 + 1 + 1 + 1 + + + + text + 62 + 1 + 1 + 1 + O padrão de senha são os 8 primeiros dígitos do CNPJ + + + + select + adminhtml/system_config_source_yesno + 63 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 64 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 65 + 1 + 1 + 1 + + + + text + 66 + 1 + 1 + 1 + Códigos separados por vírgula. + + + + text + 70 + 1 + 1 + 1 + + Mínimo de 2 cm.]]> + + + + text + 80 + 1 + 1 + 1 + + Mínimo de 16 cm.]]> + + + + text + 90 + 1 + 1 + 1 + + Mínimo de 11 cm.]]> + + + + text + 100 + 1 + 1 + 1 + + + + text + 110 + 1 + 1 + 1 + + + + text + 120 + 1 + 1 + 1 + Utilize o mesmo formato de peso configurado no módulo, kilos ou gramas. + + + + text + 130 + 1 + 1 + 1 + Essa taxa será adicionada ao valor do frete. + + + + text + 131 + 1 + 1 + 1 + Adicionará mais dias aos prazos fornecidos pelos Correios. + + + + text + 135 + 1 + 1 + 1 + + + + text + 140 + 1 + 1 + 1 + + + + select + free-method + PedroTeixeira_Correios_Model_Source_FreeMethods + 150 + 1 + 1 + 1 + Quando usar um cupom oferecendo frete gratuito, qual serviço será gratuito. + Lembre-se de habilitar o serviço. + + + + + textarea + 160 + 1 + 1 + 1 + + + + textarea + 170 + 1 + 1 + 1 + + + + textarea + 180 + 1 + 1 + 1 + + + + textarea + 185 + 1 + 1 + 1 + + + + textarea + 190 + 1 + 1 + 1 + + + + textarea + 191 + 1 + 1 + 1 + + + + text + 230 + 1 + 1 + 1 + + +
+
+
+
+
diff --git a/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/mysql4-install-4.0.0.php b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/mysql4-install-4.0.0.php new file mode 100755 index 0000000..016c16f --- /dev/null +++ b/app/code/community/PedroTeixeira/Correios/sql/pedroteixeira_correios_setup/mysql4-install-4.0.0.php @@ -0,0 +1,64 @@ + + * @license http://opensource.org/licenses/MIT + */ + +$installer = $this; + +/* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */ +$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); + +$installer->startSetup(); + +// Adiciona o volume como atributo do produto +$codigo = 'volume_comprimento'; +$config = array( + 'position' => 1, + 'required' => 0, + 'label' => 'Comprimento (cm)', + 'type' => 'int', + 'input' => 'text', + 'apply_to' => 'simple,bundle,grouped,configurable', + 'note' => 'Comprimento da embalagem do produto (Para cálculo de PAC, mínimo de 16)' +); + +$setup->addAttribute('catalog_product', $codigo, $config); + +// Adiciona o volume como atributo do produto +$codigo = 'volume_altura'; +$config = array( + 'position' => 1, + 'required' => 0, + 'label' => 'Altura (cm)', + 'type' => 'int', + 'input' => 'text', + 'apply_to' => 'simple,bundle,grouped,configurable', + 'note' => 'Altura da embalagem do produto (Para cálculo de PAC, mínimo de 2)' +); + +$setup->addAttribute('catalog_product', $codigo, $config); + +// Adiciona o volume como atributo do produto +$codigo = 'volume_largura'; +$config = array( + 'position' => 1, + 'required' => 0, + 'label' => 'Largura (cm)', + 'type' => 'int', + 'input' => 'text', + 'apply_to' => 'simple,bundle,grouped,configurable', + 'note' => 'Largura da embalagem do produto (Para cálculo de PAC, mínimo de 11)' +); + +$setup->addAttribute('catalog_product', $codigo, $config); + +$installer->endSetup(); +?> \ No newline at end of file diff --git a/app/etc/modules/PedroTeixeira_Correios.xml b/app/etc/modules/PedroTeixeira_Correios.xml new file mode 100755 index 0000000..76cb436 --- /dev/null +++ b/app/etc/modules/PedroTeixeira_Correios.xml @@ -0,0 +1,22 @@ + + + + + + true + community + + +