Commit 791b9ed5cb69d2306f31d1a50dac35684b1c3b71
1 parent
4cc8ac6c
basket
Showing
1 changed file
with
13 additions
and
0 deletions
Show diff stats
models/Basket.php
@@ -8,6 +8,8 @@ | @@ -8,6 +8,8 @@ | ||
8 | use yii\web\Cookie; | 8 | use yii\web\Cookie; |
9 | use yii\web\NotFoundHttpException; | 9 | use yii\web\NotFoundHttpException; |
10 | 10 | ||
11 | + | ||
12 | + | ||
11 | /** | 13 | /** |
12 | * Class Basket to work with basket | 14 | * Class Basket to work with basket |
13 | */ | 15 | */ |
@@ -19,6 +21,9 @@ | @@ -19,6 +21,9 @@ | ||
19 | * @var \yii\web\Session | 21 | * @var \yii\web\Session |
20 | */ | 22 | */ |
21 | protected $session; | 23 | protected $session; |
24 | + public $config = [ | ||
25 | + 'count_all' => false, | ||
26 | + ]; | ||
22 | 27 | ||
23 | /** | 28 | /** |
24 | * Basket constructor. | 29 | * Basket constructor. |
@@ -165,9 +170,17 @@ | @@ -165,9 +170,17 @@ | ||
165 | public function getCount(): int | 170 | public function getCount(): int |
166 | { | 171 | { |
167 | $data = $this->getData(); | 172 | $data = $this->getData(); |
173 | + if ($this->config['count_all']){ | ||
174 | + $all_data = 0; | ||
175 | + foreach($data as $item){ | ||
176 | + $all_data +=$item['count']; | ||
177 | + } | ||
178 | + return $all_data; | ||
179 | + } | ||
168 | return count($data); | 180 | return count($data); |
169 | } | 181 | } |
170 | 182 | ||
183 | + | ||
171 | /** | 184 | /** |
172 | * Get sum of variants in basket | 185 | * Get sum of variants in basket |
173 | * | 186 | * |