From 04e8796dd718ab440fe632f8d356a757f1c7dfb2 Mon Sep 17 00:00:00 2001 From: yarik Date: Thu, 1 Dec 2016 22:25:57 +0200 Subject: [PATCH] Not in stock --- models/Basket.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/models/Basket.php b/models/Basket.php index a5e3073..1f6ff6c 100755 --- a/models/Basket.php +++ b/models/Basket.php @@ -33,7 +33,7 @@ } parent::__construct($config); } - + /** * Increment product variant with $product_variant_id count by 1 * @@ -56,8 +56,8 @@ ]; } } - if($data[$product_variant_id]['count'] <= 0) { - unset($data[$product_variant_id]); + if ($data[ $product_variant_id ][ 'count' ] <= 0) { + unset( $data[ $product_variant_id ] ); } $this->setData($data); } @@ -155,7 +155,7 @@ $models = $this->findModels(array_keys($data)); $sum = 0; foreach ($models as $model) { - $sum += $model->price * $data[$model->id]['count']; + $sum += $model->price * $data[ $model->id ][ 'count' ]; } return $sum; } @@ -175,6 +175,13 @@ */ $model = ProductVariant::find() ->where([ 'product_variant.id' => $product_variant_id ]) + ->andWhere( + [ + '>', + 'product_variant.stock', + 0, + ] + ) ->joinWith('lang') ->one(); if (empty( $model )) { -- libgit2 0.21.4