common/components/CartFunctionality.php
/*
     * This function count the cart elements
     */
This function count the cart elements
This function count the cart elements
public static function Count() {
        $date = Yii::$app->CartFunctionality->date();
        Cart::deleteAll('date <= :date', ['date' => $date]);
        if (isset(Yii::$app->user->identity->id)) {
            if (isset(Yii::$app->session['temp_user'])) {
                Yii::$app->CartFunctionality->changecart(Yii::$app->session['temp_user']);
            }
        }
        $condition = Yii::$app->CartFunctionality->usercheck();
        $cart_items = Cart::find()->where($condition)->all();
        if (!empty($cart_items)) {
            $cart_items = Cart::find()->where($condition)->all();
            return count($cart_items);
        } else {
            return '0';
        }
    }
public static function Count ( ) { $ date = Yii :: $ app -> CartFunctionality -> date ( ) ; Cart :: deleteAll ( 'date <= :date' , [ 'date' => $ date ] ) ; if ( isset ( Yii :: $ app -> user -> identity -> id ) ) { if ( isset ( Yii :: $ app -> session [ 'temp_user' ] ) ) { Yii :: $ app -> CartFunctionality -> changecart ( Yii :: $ app -> session [ 'temp_user' ] ) ; } } $ condition = Yii :: $ app -> CartFunctionality -> usercheck ( ) ; $ cart_items = Cart :: find ( ) -> where ( $ condition ) -> all ( ) ; if ( ! empty ( $ cart_items ) ) { $ cart_items = Cart :: find ( ) -> where ( $ condition ) -> all ( ) ; return count ( $ cart_items ) ; } else { return '0' ; } }
This function count the cart elements
This function count the cart elements