Security Level: All-users
I spent hours with searching why carriercompare module doesn't work at all on PrestaShop. I mean, when you change the country, delivery costs are wrong calculated.
In fact, this is because it uses an inadequate function that always fix the delivery zone to the default Country zone id !
1. ajax.php - line 42 : Calls getCarriersListByIdZone()
2. carriercompare.php - Line 118 : getCarriersListByIdZone() CALLS Carrier::getCarriersForOrder()
3. classes/carrier.php - Line 502 : getCarriersForOrder() CALLS getOrderShippingCost() (the price here is wrong)
function getOrderShippingCost() (line 977)
Line xxx :
if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT)
$shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight(), $id_zone);
--> Here in my case, $shipping_cost should be calculated with the price that corresponds to the weight range for the selected area, but it isn't the case. In fact, $id_zone corresponds to the default zone ID, and not the selected zone id.
Line xxx :
AND Customer::customerHasAddress($this->id_customer, $this->id_address_delivery))
$id_zone = Address::getZoneById((int)($this->id_address_delivery));
> THE PROBLEM STANDS HERE ! First condition (if) is not met (there is no id_address_delivery because the user is not logged (and module is not displayed when logged) & for the same reason, Customer::customerHasAddress($this>id_customer, $this->id_address_delivery)) is empty !!!!!
The "else" is also used and $id_zone is defined to default country zone id....
So I think this function can't be used to calculate delivery costs for visitors.