public function cmdDeleteCart()
    {
        $id = $this->getParam(0);

        $options = null;

        if ($this->getParam('user')) {
            $options = array('user_id' => $id);
        } else if ($this->getParam('sku')) {
            $options = array('sku' => $id);
        } else if ($this->getParam('order')) {

            if (!is_numeric($id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $options = array('order_id' => $id);
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->cart->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->cart->delete($item['cart_id']);
            }

            $result = $count && $count == $deleted;

        } else {

            if (empty($id) || !is_numeric($id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $result = $this->cart->delete($id);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdDeleteCart()
    {
        $id = $this->getParam(0);

        $options = null;

        if ($this->getParam('user')) {
            $options = array('user_id' => $id);
        } else if ($this->getParam('sku')) {
            $options = array('sku' => $id);
        } else if ($this->getParam('order')) {

            if (!is_numeric($id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $options = array('order_id' => $id);
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->cart->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->cart->delete($item['cart_id']);
            }

            $result = $count && $count == $deleted;

        } else {

            if (empty($id) || !is_numeric($id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $result = $this->cart->delete($id);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }
public function cmdDeleteCart ( ) { $ id = $ this -> getParam ( 0 ) ; $ options = null ; if ( $ this -> getParam ( 'user' ) ) { $ options = array ( 'user_id' => $ id ) ; } else if ( $ this -> getParam ( 'sku' ) ) { $ options = array ( 'sku' => $ id ) ; } else if ( $ this -> getParam ( 'order' ) ) { if ( ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ options = array ( 'order_id' => $ id ) ; } if ( isset ( $ options ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> cart -> getList ( $ options ) as $ item ) { $ count ++ ; $ deleted += ( int ) $ this -> cart -> delete ( $ item [ 'cart_id' ] ) ; } $ result = $ count && $ count == $ deleted ; } else { if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ result = $ this -> cart -> delete ( $ id ) ; } if ( empty ( $ result ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; }
Callback for "cart-delete" command
Callback for cart - delete command