public function saveCSVData($csv_data) { if (!DpdPolandCSV::deleteAllData()) { return false; } $success = true; foreach ($csv_data as $data) { $csv_obj = new DpdPolandCSV(); $csv_obj->id_shop = (int) $this->context->shop->id; $csv_obj->iso_country = $data[DpdPolandCSV::COLUMN_COUNTRY]; $csv_obj->weight_from = $data[DpdPolandCSV::COLUMN_WEIGHT_FROM]; $csv_obj->weight_to = $data[DpdPolandCSV::COLUMN_WEIGHT_TO]; $csv_obj->parcel_price = $data[DpdPolandCSV::COLUMN_PARCEL_PRICE]; $csv_obj->id_carrier = $data[DpdPolandCSV::COLUMN_CARRIER]; $csv_obj->cod_price = $data[DpdPolandCSV::COLUMN_COD_PRICE]; $success &= $csv_obj->save(); } return $success; }
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]; }