public function getOrderShippingCostExternal($cart) { if (!$this->soapClientExists() || !$this->checkModuleAvailability()) { return false; } $disabled_countries_ids = DpdPolandCountry::getDisabledCountriesIDs(); $id_country = (int) Tools::getValue('id_country'); if (!$id_country) { $country = Address::getCountryAndState((int) $cart->id_address_delivery); $id_country = $country['id_country']; } if (!($id_method = self::getMethodIdByCarrierId($this->id_carrier))) { self::$carriers[$this->id_carrier] = false; return false; } if (!$id_country || in_array($id_country, $disabled_countries_ids) && $id_method == _DPDPOLAND_CLASSIC_ID_) { return false; } if ($id_country) { $zone = Country::getIdZone($id_country); } else { return false; } if (!$this->id_carrier) { return false; } if ($id_country == Country::getByIso(self::POLAND_ISO_CODE) && $id_method == _DPDPOLAND_CLASSIC_ID_ || $id_country != Country::getByIso(self::POLAND_ISO_CODE) && $id_method == _DPDPOLAND_STANDARD_COD_ID_ || $id_country != Country::getByIso(self::POLAND_ISO_CODE) && $id_method == _DPDPOLAND_STANDARD_ID_) { return false; } if (isset(self::$carriers[$this->id_carrier])) { return self::$carriers[$this->id_carrier]; } $total_weight = self::convertWeight($cart->getTotalWeight()); if (Configuration::get(DpdPolandConfiguration::PRICE_CALCULATION_TYPE) == DpdPolandConfiguration::PRICE_CALCULATION_PRESTASHOP) { $carrier = new Carrier($this->id_carrier); $price = $carrier->getDeliveryPriceByWeight($total_weight, $zone); self::$carriers[$this->id_carrier] = $price; return self::$carriers[$this->id_carrier]; } $price = DpdPolandCSV::getPrice($total_weight, $id_method, $cart); if ($price === 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); return self::$carriers[$this->id_carrier]; }
private static function disableCountryById($context, $id_country, $id_shop = null) { if ($id_shop === null) { $id_shop = (int) $context->shop->id; } $dpdpoland_country = new DpdPolandCountry(); $dpdpoland_country->id_country = (int) $id_country; $dpdpoland_country->id_shop = (int) $id_shop; $dpdpoland_country->enabled = 0; return $dpdpoland_country->save(); }