public function getDeliveryTime($countryCode, $purchaseQuantity = null, $stockLevel = null, $languageISO = null)
{
if(!isset($languageISO))
{
//Language-Fallback fuer Exportformate - #6663. ToDo: Abfrage der aktuellen Sprache in Session-Class oder System-Class auslagern
if (!isset($_SESSION['cISOSprache'])) {
$oSprache = gibStandardsprache(true);
$_SESSION['cISOSprache'] = $oSprache->cISO;
}
$languageISO = $_SESSION['cISOSprache'];
}
if (isset($purchaseQuantity)) {
$purchaseQuantity = (float) $purchaseQuantity;
} else {
$purchaseQuantity = $this->fAbnahmeintervall > 0 ? $this->fAbnahmeintervall : 1; // + $this->getPurchaseQuantityFromCart();
}
if (!is_numeric($purchaseQuantity) || $purchaseQuantity <= 0) {
$purchaseQuantity = 1;
}
if (isset($stockLevel) && is_numeric($stockLevel)) {
$stockLevel = (float) $stockLevel;
} else {
$stockLevel = $this->fLagerbestand;
}
$favShipping = $this->getFavourableShipping($countryCode);
if ($favShipping === null || $this->inWarenkorbLegbar <= 0) {
return '';
}
//set default values
$estimatedDelivery = ''; //$favShipping->oVersandartSprache_arr[$languageISO]->cLieferdauer;
$processingTime = 0;
$minDeliveryDays = (strlen(trim($favShipping->nMinLiefertage)) > 0) ? intval($favShipping->nMinLiefertage) : 2;
$maxDeliveryDays = (strlen(trim($favShipping->nMaxLiefertage)) > 0) ? intval($favShipping->nMaxLiefertage) : 3;
if ($this->FunktionsAttribute['processingtime'] > 0) {
$processingTime = intval($this->FunktionsAttribute['processingtime']);
$minDeliveryDays += $processingTime;
$maxDeliveryDays += $processingTime;
}
// product available in the future?
if ($this->nErscheinendesProdukt && strtotime($this->dErscheinungsdatum) > time()) {
$minDeliveryDays += calculateDaysBetween($this->dErscheinungsdatum, date('Y-m-d', time()));
$maxDeliveryDays += calculateDaysBetween($this->dErscheinungsdatum, date('Y-m-d', time()));
}
else
if ($this->cLagerBeachten == "Y" && ($stockLevel <= 0 || ($stockLevel - $purchaseQuantity < 0))) {
if ($this->FunktionsAttribute['deliverytime_outofstock'] > 0) { //prio on attribute "deliverytime_outofstock" for simple deliverytimes
$deliverytime_outofstock = intval($this->FunktionsAttribute['deliverytime_outofstock']);
$minDeliveryDays = $deliverytime_outofstock; //overrides parcel and processingtime!
$maxDeliveryDays = $deliverytime_outofstock; //overrides parcel and processingtime!
} else if ($this->FunktionsAttribute['supplytime'] > 0) { //attribute "supplytime" for merchants who do not use JTL-Wawis purchase-system
$supplyTime = intval($this->FunktionsAttribute['supplytime']);
$minDeliveryDays += $supplyTime;
$maxDeliveryDays += $supplyTime;
} else if ($this->fZulauf > 0 && strtotime($this->dZulaufDatum) >= time()) { // supplierOrder incoming?
$minDeliveryDays += calculateDaysBetween($this->dZulaufDatum, date('Y-m-d', time()));
$maxDeliveryDays += calculateDaysBetween($this->dZulaufDatum, date('Y-m-d', time()));
} else if ($this->fLieferzeit > 0 && !$this->nErscheinendesProdukt) { //product
$minDeliveryDays += intval($this->fLieferzeit);
$maxDeliveryDays += intval($this->fLieferzeit);
}
}
//set estimatedDeliverytime text
$estimatedDelivery = getDeliverytimeEstimationText($minDeliveryDays, $maxDeliveryDays);
$this->nMinDeliveryDays = $minDeliveryDays;
$this->nMaxDeliveryDays = $maxDeliveryDays;
return $estimatedDelivery;
}