aktualizacja modułu dpd

This commit is contained in:
2026-02-02 10:46:49 +01:00
parent dfc86a1895
commit 764d54f8d5
722 changed files with 70854 additions and 1051 deletions

View File

@@ -336,7 +336,7 @@ class DpdPoland extends CarrierModule
`id_sender_address` int(11) NOT NULL,
`cud` tinyint(1) NOT NULL,
`rod` tinyint(1) NOT NULL,
`dpde` tinyint(1) NOT NULL,
`dpde` tinyint(1) NOT NULL,
`dpdnd` tinyint(1) NOT NULL,
`duty` tinyint(1) NOT NULL,
`duty_amount` decimal(17,2) DEFAULT NULL,
@@ -1741,7 +1741,7 @@ class DpdPoland extends CarrierModule
return Db::getInstance()->getValue('
SELECT `id_reference`
FROM `' . _DB_PREFIX_ . 'carrier`
FROM `' . _DB_PREFIX_ . 'carrier`
WHERE `id_carrier`=' . (int)$id_carrier
);
}
@@ -2578,8 +2578,18 @@ class DpdPoland extends CarrierModule
*/
public function getOrderShippingCostExternal($cart)
{
if (!$this->soapClientExists() || !$this->checkModuleAvailability())
if (!$this->soapClientExists()) {
DpdPolandLog::addLog('getOrderShippingCostExternal: SOAP client not exists - returning false');
return false;
}
if (!$this->checkModuleAvailability()) {
$plCountry = Country::getByIso(self::POLAND_ISO_CODE);
$plnCurrency = Currency::getIdByIsoCode(_DPDPOLAND_CURRENCY_ISO_);
$curlExists = function_exists('curl_init');
DpdPolandLog::addLog('getOrderShippingCostExternal: Module not available - PL country: ' . ($plCountry ? $plCountry : 'NOT FOUND') . ', PLN currency: ' . ($plnCurrency ? $plnCurrency : 'NOT FOUND') . ', CURL: ' . ($curlExists ? 'YES' : 'NO'));
return false;
}
$disabled_countries_ids = DpdPolandCountry::getDisabledCountriesIDs();
@@ -2595,20 +2605,27 @@ class DpdPoland extends CarrierModule
}
if (!$id_method = self::getMethodIdByCarrierId($this->id_carrier)) {
DpdPolandLog::addLog('getOrderShippingCostExternal: No method found for carrier ' . $this->id_carrier . ' - returning false');
self::$carriers[$this->id_carrier] = false;
return false;
}
if (!$id_country || in_array($id_country, $disabled_countries_ids) && $id_method == _DPDPOLAND_CLASSIC_ID_)
if (!$id_country || in_array($id_country, $disabled_countries_ids) && $id_method == _DPDPOLAND_CLASSIC_ID_) {
DpdPolandLog::addLog('getOrderShippingCostExternal: Country disabled or invalid - id_country: ' . $id_country . ', method: ' . $id_method);
return false;
}
if ($id_country)
$zone = Country::getIdZone($id_country);
else
else {
DpdPolandLog::addLog('getOrderShippingCostExternal: No country - returning false');
return false;
}
if (!$this->id_carrier)
if (!$this->id_carrier) {
DpdPolandLog::addLog('getOrderShippingCostExternal: No id_carrier set - returning false');
return false;
}
$is_poland_country = $this->isPolandCountry((int)$id_country);
@@ -2617,6 +2634,7 @@ class DpdPoland extends CarrierModule
!$is_poland_country && $id_method == _DPDPOLAND_STANDARD_ID_ ||
!$is_poland_country && $id_method == _DPDPOLAND_PUDO_ID_
) {
DpdPolandLog::addLog('getOrderShippingCostExternal: Country/method mismatch - is_poland: ' . ($is_poland_country ? 'YES' : 'NO') . ', method: ' . $id_method);
return false;
}
@@ -2627,26 +2645,50 @@ class DpdPoland extends CarrierModule
if (Configuration::get(DpdPolandConfiguration::PRICE_CALCULATION_TYPE) == DpdPolandConfiguration::PRICE_CALCULATION_PRESTASHOP) {
$carrier = new Carrier($this->id_carrier);
$price = $carrier->getDeliveryPriceByWeight($total_weight, $zone);
// Check carrier billing method: 1 = by weight, 2 = by price
if ($carrier->shipping_method == Carrier::SHIPPING_METHOD_PRICE) {
// Calculate by cart price
$order_total = $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING);
$price = $carrier->getDeliveryPriceByPrice($order_total, $zone);
DpdPolandLog::addLog('getOrderShippingCostExternal: PrestaShop calc BY PRICE - carrier: ' . $this->id_carrier . ', order_total: ' . $order_total . ', zone: ' . $zone . ', price: ' . ($price === false ? 'FALSE' : $price));
} else {
// Calculate by weight (default)
$price = $carrier->getDeliveryPriceByWeight($total_weight, $zone);
DpdPolandLog::addLog('getOrderShippingCostExternal: PrestaShop calc BY WEIGHT - carrier: ' . $this->id_carrier . ', weight: ' . $total_weight . ', zone: ' . $zone . ', price: ' . ($price === false ? 'FALSE' : $price));
}
if ($price === false) {
$method_name = ($carrier->shipping_method == Carrier::SHIPPING_METHOD_PRICE) ? 'price ranges' : 'weight ranges';
DpdPolandLog::addLog('getOrderShippingCostExternal: No price found - check carrier ' . $method_name . ' in PrestaShop');
self::$carriers[$this->id_carrier] = false;
return false;
}
$id_currency_pl = Currency::getIdByIsoCode(_DPDPOLAND_CURRENCY_ISO_, (int)$this->context->shop->id);
$currency_from = new Currency((int)$id_currency_pl);
$currency_to = $this->context->currency;
self::$carriers[$this->id_carrier] = Tools::convertPriceFull($price, $currency_from, $currency_to);
DpdPolandLog::addLog('getOrderShippingCostExternal: SUCCESS - final price: ' . self::$carriers[$this->id_carrier]);
return self::$carriers[$this->id_carrier];
}
$price = DpdPolandCSV::getPrice($total_weight, $id_method, $cart);
if ($price === false)
DpdPolandLog::addLog('getOrderShippingCostExternal: CSV calc - weight: ' . $total_weight . ', method: ' . $id_method . ', price: ' . ($price === false ? 'FALSE' : $price));
if ($price === false) {
DpdPolandLog::addLog('getOrderShippingCostExternal: No CSV price found - check CSV import in module config');
return false;
}
$id_currency_pl = Currency::getIdByIsoCode(_DPDPOLAND_CURRENCY_ISO_, (int)$this->context->shop->id);
$currency_from = new Currency((int)$id_currency_pl);
$currency_to = $this->context->currency;
self::$carriers[$this->id_carrier] = Tools::convertPriceFull($price, $currency_from, $currency_to);
DpdPolandLog::addLog('getOrderShippingCostExternal: SUCCESS - final price: ' . self::$carriers[$this->id_carrier]);
return self::$carriers[$this->id_carrier];
}