all() as $sb) { if (in_array($sb->cartKey, $cart_data)) { $selected[] = $sb->cartKey; } } } return $selected; } public function getTitle() { return \Yii::$app->language == 'en' ? $this->name_en : $this->name; } public function getDescription() { return \Yii::$app->language == 'en' ? $this->text : $this->text_en; } public function getFormatedPrice() { return number_format($this->price, 2, '.', ' ') . ' лв.'; } public function getMonthLabel() { if ($this->months > 1 || $this->months == 0) { return Ts::get(86); } else { return Ts::get(85); } } public function isInCart() { if (!empty($_COOKIE['cart_data']) && in_array($this->cartKey, json_decode($_COOKIE['cart_data']))) return true; return false; } public function isBtnDisabled() { $selected = self::allSelectedSubscriptions(); if (sizeof($selected) > 0 && !in_array($this->cartKey, $selected)) { return 'disabled'; } return ''; } public function getCartKey() { return Cart::encodeKey('Subscriptions', $this->id); } public function setCart(CartModel $model) { $model->title = Ts::get(97) . ' - ' . $this->getTitle(); $model->subTitle = $this->months . ' ' . $this->getMonthLabel(); $model->description = $this->getDescription(); $model->singlePrice = $this->getFormatedPrice(); $model->price = $this->price; $model->availableQuantity = 1; /********************************/ $model->name_bg = $this->name . ' (абонамент)'; $model->name_en = $this->name_en. ' (subscription)'; $model->text_bg = $this->text. " ($this->months м)"; $model->text_en = $this->text_en. " ($this->months m)"; return $model; } }