public function clearCart()
    {
        if (!\Yii::$app->user->isGuest && $this->saveToDataBase === true) {
            $order = Order::find()->where(['user_id' => \Yii::$app->user->id, 'status' => OrderStatus::STATUS_INCOMPLETE])->one();
            if (!empty($order))
                $order->delete();
        } else {
            $session = \Yii::$app->session;
            $session->remove(self::SESSION_KEY);
        }
        $this->trigger(self::EVENT_AFTER_CLEAR);
    }
public function clearCart()
    {
        if (!\Yii::$app->user->isGuest && $this->saveToDataBase === true) {
            $order = Order::find()->where(['user_id' => \Yii::$app->user->id, 'status' => OrderStatus::STATUS_INCOMPLETE])->one();
            if (!empty($order))
                $order->delete();
        } else {
            $session = \Yii::$app->session;
            $session->remove(self::SESSION_KEY);
        }
        $this->trigger(self::EVENT_AFTER_CLEAR);
    }
public function clearCart ( ) { if ( ! \ Yii :: $ app -> user -> isGuest && $ this -> saveToDataBase === true ) { $ order = Order :: find ( ) -> where ( [ 'user_id' => \ Yii :: $ app -> user -> id , 'status' => OrderStatus :: STATUS_INCOMPLETE ] ) -> one ( ) ; if ( ! empty ( $ order ) ) $ order -> delete ( ) ; } else { $ session = \ Yii :: $ app -> session ; $ session -> remove ( self :: SESSION_KEY ) ; } $ this -> trigger ( self :: EVENT_AFTER_CLEAR ) ; }
Clears cart.
Clears cart .