Skip to content

Commit

Permalink
pedro-teixeira#75 Adicionada opção de exibir aviso de área de risco.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelpatro committed Apr 9, 2015
1 parent 91313fe commit e070489
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ protected function _getQuotes()
}

$this->_appendShippingReturn((string) $servicos->Codigo, $shippingPrice, $shippingDelivery);
if ($this->getConfigFlag('show_soft_errors') && !isset($isWarnAppended)) {
$isWarnAppended = $this->_appendShippingWarning($servicos);
}
$existReturn = true;
}

Expand Down Expand Up @@ -860,4 +863,25 @@ protected function _splitPack()
}
return false;
}

/**
* Add a warning message at the top of the shipping method list.
*
* @param SimpleXMLElement $servico
*
* @return boolean
*/
protected function _appendShippingWarning(SimpleXMLElement $servico)
{
$id = (string) $servico->Erro;
$ids = explode(',', $this->getConfigData('soft_errors'));
if (in_array($id, $ids)) {
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setErrorMessage((string)$servico->MsgErro);
$this->_result->append($error);
return true;
}
return false;
}
}
1 change: 1 addition & 0 deletions app/code/community/PedroTeixeira/Correios/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<title>Correios</title>
<postmethods>40010</postmethods>
<soft_errors>009,010,011</soft_errors>
<show_soft_errors>0</show_soft_errors>
<prazo_entrega>0</prazo_entrega>
<check_dimensions>1</check_dimensions>
<min_order_value>0</min_order_value>
Expand Down
9 changes: 9 additions & 0 deletions app/code/community/PedroTeixeira/Correios/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,15 @@
<show_in_store>1</show_in_store>
<comment>O pacote é dividido, caso o carrinho exceda os limites de peso e tamanho, para todos os serviços. A divisão se repete até que os limites sejam válidos, para um ou mais serviços.</comment>
</split_pack>
<show_soft_errors translate="label">
<label>Exibir Alerta de Área de Risco</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>269</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</show_soft_errors>
<sort_order translate="label">
<label>Ordenar Por</label>
<frontend_type>text</frontend_type>
Expand Down

0 comments on commit e070489

Please sign in to comment.