Commit 04e8796dd718ab440fe632f8d356a757f1c7dfb2
1 parent
6bd5b95e
Not in stock
Showing
1 changed file
with
11 additions
and
4 deletions
Show diff stats
models/Basket.php
@@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
33 | } | 33 | } |
34 | parent::__construct($config); | 34 | parent::__construct($config); |
35 | } | 35 | } |
36 | - | 36 | + |
37 | /** | 37 | /** |
38 | * Increment product variant with $product_variant_id count by 1 | 38 | * Increment product variant with $product_variant_id count by 1 |
39 | * | 39 | * |
@@ -56,8 +56,8 @@ | @@ -56,8 +56,8 @@ | ||
56 | ]; | 56 | ]; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | - if($data[$product_variant_id]['count'] <= 0) { | ||
60 | - unset($data[$product_variant_id]); | 59 | + if ($data[ $product_variant_id ][ 'count' ] <= 0) { |
60 | + unset( $data[ $product_variant_id ] ); | ||
61 | } | 61 | } |
62 | $this->setData($data); | 62 | $this->setData($data); |
63 | } | 63 | } |
@@ -155,7 +155,7 @@ | @@ -155,7 +155,7 @@ | ||
155 | $models = $this->findModels(array_keys($data)); | 155 | $models = $this->findModels(array_keys($data)); |
156 | $sum = 0; | 156 | $sum = 0; |
157 | foreach ($models as $model) { | 157 | foreach ($models as $model) { |
158 | - $sum += $model->price * $data[$model->id]['count']; | 158 | + $sum += $model->price * $data[ $model->id ][ 'count' ]; |
159 | } | 159 | } |
160 | return $sum; | 160 | return $sum; |
161 | } | 161 | } |
@@ -175,6 +175,13 @@ | @@ -175,6 +175,13 @@ | ||
175 | */ | 175 | */ |
176 | $model = ProductVariant::find() | 176 | $model = ProductVariant::find() |
177 | ->where([ 'product_variant.id' => $product_variant_id ]) | 177 | ->where([ 'product_variant.id' => $product_variant_id ]) |
178 | + ->andWhere( | ||
179 | + [ | ||
180 | + '>', | ||
181 | + 'product_variant.stock', | ||
182 | + 0, | ||
183 | + ] | ||
184 | + ) | ||
178 | ->joinWith('lang') | 185 | ->joinWith('lang') |
179 | ->one(); | 186 | ->one(); |
180 | if (empty( $model )) { | 187 | if (empty( $model )) { |