/** * Deletes the payment_basket and all related payment_items in the database * as well as corresponding newly created but inactive products * * @param int $oid Key id of row to delete (otherwise it's the one of $this) * @return boolean TRUE if OK, FALSE if error */ public function delete( $oid = null ) { global $_CB_database; if ( $oid ) { $k = $this->_tbl_key; $this->$k = (int) $oid; } $subscriptions =& $this->getSubscriptions(); foreach ( $subscriptions as $k => $v ) { if ( is_object( $v ) && in_array( $v->status, array( 'R', 'I' ) ) ) { if ( ! $subscriptions[$k]->hasPendingPayment( $this->id ) ) { $subscriptions[$k]->delete(); } } } $query = "DELETE FROM #__cbsubs_payment_items" . "\n WHERE payment_basket_id = ". (int) $this->id; $_CB_database->setQuery( $query ); if ( !$_CB_database->query() ) { trigger_error( "delete paymentItems error:".htmlspecialchars($_CB_database->getErrorMsg()), E_USER_ERROR ); return false; } if ( ! $this->deleteTotalizers() ) { return false; } if ( ! parent::delete( $oid ) ) { trigger_error( "delete paymentBasket error:".htmlspecialchars( $this->getError() ), E_USER_ERROR ); return false; } return true; }