You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR updates the logic responsible for handling delivery methods that contain a delivery_note related to risk areas.
Previously, the module appended an error to the shipping rate result (via append($error) or setError(true)), which prevents Magento from displaying any valid shipping methods, even when they exist. This happened regardless of whether delivery_risk_areas was enabled or disabled, resulting in checkout being blocked unnecessarily.
The new implementation ensures that:
No error is created when delivery_risk_areas is disabled.
Only the delivery method containing a risk-related delivery_note is skipped when risk areas are turned off.
Valid delivery methods continue to be displayed normally.
Logging occurs only when risk area handling is enabled.
Error behavior now aligns with configuration expectations.
Checklist:
Changes are consistent with the project's coding style.
robsoned
changed the title
prevent risk area error when delivery_risk_areas is disabled
Fix risk area handling to prevent unwanted rate errors and ensure valid methods are still displayed
Dec 10, 2025
Revisei a mudança e o fix está correto — remover o setError(true)/append($error) incondicional resolve a causa raiz do #47 (um único delivery_note marcava o RateResult inteiro como erro e o Magento escondia todos os métodos da Intelipost). A nova lógica guiada pela config está coerente:
delivery_risk_areas = 0 → continue, pula só o método com nota de risco;
delivery_risk_areas = 1 → loga e deixa o método passar normalmente.
Confirmei também que a remoção de $riskWarning é segura (só era usado nas linhas removidas), que $this->logger existe/está injetado, e que $riskAreaMessage segue definido.
Ponto que quero confirmar antes de aprovar: com essa mudança, o riskareamsg deixa de ser exibido ao cliente — antes ele ia para o errorMessage (visível no checkout, ainda que de forma quebrada) e agora só vai para o log. Isso deixa o campo de config riskareamsg sem efeito user-facing. Está alinhado com o texto do #47 ("optionally log or annotate it"), mas é a única mudança de comportamento não puramente corretiva. A intenção é mesmo não mostrar nenhum aviso ao comprador em área de risco? Se o aviso precisar continuar visível, dá para anexar como RateResult\Method informativo em vez de Error, sem voltar a poluir o resultado com setError(true).
Nits menores (não bloqueiam): há uma linha em branco sobrando dentro do bloco if antes do }; e, com risco ligado, agora cada método com delivery_note gera um warning (antes o guard !$riskWarning limitava a 1 por cotação) — aceitável, só aumenta o volume de log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This PR updates the logic responsible for handling delivery methods that contain a delivery_note related to risk areas.
Previously, the module appended an error to the shipping rate result (via append($error) or setError(true)), which prevents Magento from displaying any valid shipping methods, even when they exist. This happened regardless of whether delivery_risk_areas was enabled or disabled, resulting in checkout being blocked unnecessarily.
The new implementation ensures that:
Checklist:
Testing Instructions: