[Since this is a brazilian focused module and it will be used only by brazilians, i will post in portuguese]

Já constatei esse problema tem algum tempo, mas não postei antes porque achei que resolvia sozinho. Só que fui deixando e agora ta em cima da hora hehe.

O módulo não esta calculando direito o peso, fica indicando Peso excedido (erro: -4). Acredito que seja um problema de conversão das unidades de medida, pelo pouco que consegui mexer até agora, parece que ele trata por exemplo 200 gramas como 200 kilogramas pois se colocar o peso como 1 ele faz o calculo como se fosse 1kg.

Estarei trabalhando no código pra ver se encontro o problema e achando eu posto um patch, mas toda ajuda seria bem vinda, vai que é só alguma config que eu errei, pois o meu módulo original de frete não tinha esse problema.

Em anexo duas imagens, uma com peso 1 que "funciona" e outra com peso 200, ambos configurados na página do produto para serem em gramas.

abs

CommentFileSizeAuthor
peso.jpg52.53 KBdiegohermes
peso2.jpg71.61 KBdiegohermes

Comments

diegohermes’s picture

Priority: Critical » Normal

Ta loco, foi só criar o tópico que eu achei a solução, era bem simples e não tinha percebido, o erro todo acontece porque o módulo supoem que a unidade de medida padrão configurada da loja é kg, se trocar para grama ou qualquer outra, ele se perde nos calculos.

Bastou alterar para kg novamente que o módulo passa a calcular corretamente. De qualquer jeito, é um bug que seria bom tratar ou ainda mais simples, informar na documentação sobre essa "limitação".

Vou mudar a prioridade, mas manter o tópico ativo, deixo a sua escolha se fecha ele ou não.

abs

agentrickard’s picture

Yes, but posting in Portuguese prevents others from checking for API errors. That's why we use English.

diegohermes’s picture

You are right agentrickard, sorry about that.

Anyway, the problem is about the fact that the module consider that the default weight measure is kg, if you switch that to grams for example, the module will do wrong calculations, i realize that after creating this issue, so a immediate solution is use kg as the default weight measure and add this info in the readme file.

Sorry for the bad english, i need to sleep a little.

regards

pasqualle’s picture

Node 600000. Congratulations!

wasare’s picture

diegohermes,

Thanks for this issue report.

I'm planning check the default weight unit and convert it to kg before fetch the shipping quotes.

wasare’s picture

Status: Active » Needs work
wasare’s picture

Assigned: Unassigned » wasare
lourenzo’s picture

I have a fix for it working locally, but before commiting, I'd like to as why we're using

uc_cart_get_contents(uc_cart_get_id(), 'rebuild');

instead of the argument passed by ubercart.

$products

In my local debugging, the $products variable seems ok, and contains the weight_units key which enables to calculate and format the weight in the spected unit expected by correios (decimal kilograms).

Although, there is a comment in code saying that just using $products can cause errors. In which context does it happen?

lourenzo’s picture

Assigned: wasare » lourenzo
Status: Needs work » Fixed

Just fixed it in CVS, the question was really simple.

on the line:

$shipment->weight += $product->weight * $product->qty * uc_weight_conversion($node->weight_units, $weight_unit);

The calculation was using the variable uc_weight_unit as the wanted format, but we want it to be in kilograms.

Changing to:

$shipment->weight += $product->weight * $product->qty * uc_weight_conversion($node->weight_units, 'kg');

Just solved the problem.

Fixed in cvs.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.