diff --git a/helpers/FilterHelper.php b/helpers/FilterHelper.php index d763336..4b1fec7 100755 --- a/helpers/FilterHelper.php +++ b/helpers/FilterHelper.php @@ -142,16 +142,17 @@ $query->andWhere([ 'product.id' => $last_query ]); } } - + /** * Tax Option filter * * @param string[] $params * @param \yii\db\Query|null $last_query + * @param bool $in_stock * - * @return Query + * @return \yii\db\Query */ - private static function filterOptions(array $params, Query $last_query = null): Query + private static function filterOptions(array $params, Query $last_query = null, bool $in_stock = true): Query { $variant_query = ( new Query() )->distinct() ->select('product_variant.product_id as products') @@ -169,6 +170,9 @@ 'tax_option_lang.tax_option_id = tax_option.id' ) ->where([ 'tax_option_lang.alias' => $params ]); + if($in_stock) { + $variant_query->andWhere(['!=', 'product_variant.stock', 0]); + } $product_query = ( new Query() )->distinct() ->select('product_option.product_id as products') ->from('product_option') -- libgit2 0.21.4