public function isContainsProduct($productId, $combinationId = null)
    {
        if (Yii::$app->user->isGuest) {
            if (!empty(Yii::$app->session[self::SESSION_KEY])) {
                $sessionProducts = Yii::$app->session[self::SESSION_KEY];

                foreach ($sessionProducts as $item) {
                    $condition = (empty($combinationId))
                        ? (ArrayHelper::getValue($item, 'id') == $productId)
                        : (ArrayHelper::getValue($item, 'id') == $productId && ArrayHelper::getValue($item, 'combinationId') == $combinationId);

                    if($condition) {
                        return $condition;
                    }
                }
            }
        } else {
            /** @var Order $order */
            $order = Order::find()
                ->where(['user_id' => Yii::$app->user->id, 'status' => OrderStatus::STATUS_INCOMPLETE])
                ->one();

            if (!empty($order)) {
                $condition = (empty($combinationId))
                    ? ['order_id' => $order->id, 'product_id' => $productId]
                    : ['order_id' => $order->id, 'product_id' => $productId, 'combination_id' => $combinationId];

                $product = OrderProduct::find()
                    ->where($condition)
                    ->one();

                return (!empty($product));
            }
        }

        return false;
    }
public function isContainsProduct($productId, $combinationId = null)
    {
        if (Yii::$app->user->isGuest) {
            if (!empty(Yii::$app->session[self::SESSION_KEY])) {
                $sessionProducts = Yii::$app->session[self::SESSION_KEY];

                foreach ($sessionProducts as $item) {
                    $condition = (empty($combinationId))
                        ? (ArrayHelper::getValue($item, 'id') == $productId)
                        : (ArrayHelper::getValue($item, 'id') == $productId && ArrayHelper::getValue($item, 'combinationId') == $combinationId);

                    if($condition) {
                        return $condition;
                    }
                }
            }
        } else {
            /** @var Order $order */
            $order = Order::find()
                ->where(['user_id' => Yii::$app->user->id, 'status' => OrderStatus::STATUS_INCOMPLETE])
                ->one();

            if (!empty($order)) {
                $condition = (empty($combinationId))
                    ? ['order_id' => $order->id, 'product_id' => $productId]
                    : ['order_id' => $order->id, 'product_id' => $productId, 'combination_id' => $combinationId];

                $product = OrderProduct::find()
                    ->where($condition)
                    ->one();

                return (!empty($product));
            }
        }

        return false;
    }
public function isContainsProduct ( $ productId , $ combinationId = null ) { if ( Yii :: $ app -> user -> isGuest ) { if ( ! empty ( Yii :: $ app -> session [ self :: SESSION_KEY ] ) ) { $ sessionProducts = Yii :: $ app -> session [ self :: SESSION_KEY ] ; foreach ( $ sessionProducts as $ item ) { $ condition = ( empty ( $ combinationId ) ) ? ( ArrayHelper :: getValue ( $ item , 'id' ) == $ productId ) : ( ArrayHelper :: getValue ( $ item , 'id' ) == $ productId && ArrayHelper :: getValue ( $ item , 'combinationId' ) == $ combinationId ) ; if ( $ condition ) { return $ condition ; } } } } else { /** @var Order $order */ $ order = Order :: find ( ) -> where ( [ 'user_id' => Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( ! empty ( $ order ) ) { $ condition = ( empty ( $ combinationId ) ) ? [ 'order_id' => $ order -> id , 'product_id' => $ productId ] : [ 'order_id' => $ order -> id , 'product_id' => $ productId , 'combination_id' => $ combinationId ] ; $ product = OrderProduct :: find ( ) -> where ( $ condition ) -> one ( ) ; return ( ! empty ( $ product ) ) ; } } return false ; }
Checks if the cart contains the product.

@param integer $productId [[Product]] id.
@param null|integer $combinationId [[Combination]] id.
@return bool whether the cart contains the product
Checks if the cart contains the product .