settings = $settings; } /** * @return array */ public function getSettings() { return $this->settings; } /** * @param bool $isAvailableWhenOutOfStock */ public function setIsAvailableWhenOutOfStock($isAvailableWhenOutOfStock) { $this->isAvailableWhenOutOfStock = $isAvailableWhenOutOfStock; } /** * @return bool */ public function isAvailableWhenOutOfStock() { return $this->isAvailableWhenOutOfStock; } public function getStatus($product, $productQty) { $settings = $this->getSettings(); $inStock = !empty($settings['label_in_stock_text']) ? $settings['label_in_stock_text'] : $product->available_now; $inStock = !empty($inStock) ? $inStock : $settings['configurationLang']['PS_LABEL_IN_STOCK_PRODUCTS']; $outOfStockAllowed = !empty($settings['label_out_of_stock_text']) ? $settings['label_out_of_stock_text'] : $product->available_later; $outOfStockAllowed = !empty($outOfStockAllowed) ? $outOfStockAllowed : $settings['configurationLang']['PS_LABEL_OOS_PRODUCTS_BOA']; $outOfStockDenied = !empty($settings['label_on_demand_stock_text']) ? $settings['label_on_demand_stock_text'] : $settings['configurationLang']['PS_LABEL_OOS_PRODUCTS_BOD']; if ($product->available_for_order != 1 && $product->online_only != 1) { return $outOfStockDenied; } if ($productQty > 0) { return $inStock; } if ($productQty == 0 && $this->isAvailableWhenOutOfStock()) { return $outOfStockAllowed; } if ($productQty == 0 && !$this->isAvailableWhenOutOfStock()) { return $outOfStockDenied; } return ''; } }