Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange Weight-check behaviour #13

Open
remcotjeerdsma opened this issue May 16, 2019 · 3 comments
Open

Strange Weight-check behaviour #13

remcotjeerdsma opened this issue May 16, 2019 · 3 comments

Comments

@remcotjeerdsma
Copy link

remcotjeerdsma commented May 16, 2019

In the sourcecode of DpdLabelGenerator.php, there are some arbitrary values in the weight check.
If weights are not set in the shop, it assumes that the item weighs 5kg, which leads to unexplainable errors in frontend when creating labels for orders. Please remove this strange default value or at least explain it in documentation (or the error).

Also, weight is entered in KG's in prestashop, then multiplied by 100 (?) in the plugin and checked against a limit of 31,5 * 100, I assume this is supposed to avoid rounding errors, but multiplying by 1000 (to compare in grams) would make more sense.

$weightTotal = 0;
		foreach($orderDetails as $orderDetail){
			if($orderDetail['product_weight'] == 0){
				$orderDetail['product_weight'] = 5;
			}
			$weightTotal += $orderDetail['product_weight'] * $orderDetail['product_quantity'];
		}
		$weightTotal *= 100;

...

if($weightTotal / $parcels >= 31.5 * 100){
			$this->errors[] = $this->dpdError->get('WEIGHT_TO_HEAVY');
			//TODO create log that the weight is to big
		}
@dpdplugin
Copy link
Contributor

Thanks for your reply, but the API needs a parcel weight that is in grams and rounded in 10 gram units without decimal delimiter (e.g. 300 equals 3kg). So a 1000 would actually make more sense, but because of how the API was setup, the calculation is right.

@remcotjeerdsma
Copy link
Author

That explains! Thanks for commenting on this :-)
Still leaves the part where it randomly assigns weight to invoice lines in tact though.
I could not ship serveral of my parcels because the amount of invoice lines * 5 kg resulted in a weight over 31,5 kg, although the actual package is onlye a few kilo's.

I understand this would be solved by adding weight to all the products, but that should not be strictly necessary, I think.

@dpdplugin
Copy link
Contributor

Thank you for your reply, we will look into the 5kg issue resulting into an order above the 31.5kg limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants