DPDBeNeLux / DPD-Shipping-for-Prestashop-1.7

Let op: er zijn nieuwe DPD plugins (BETA versie) beschikbaar met belangrijke nieuwe functionaliteiten. De oude plugins zullen na Brexit niet meer goed functioneren, download daarom de nieuwe versie op Github/DPDconnect.
GNU General Public License v3.0
1 stars 2 forks source link

Strange Weight-check behaviour #13

Open remcotjeerdsma opened 5 years ago

remcotjeerdsma commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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