WC_CLI_REST_Command::delete_item()
Delete an existing item.
Method of the class: WC_CLI_REST_Command{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_CLI_REST_Command = new WC_CLI_REST_Command(); $WC_CLI_REST_Command->delete_item( $args, $assoc_args );
- $args(array) (required)
- WP-CLI positional arguments.
- $assoc_args(array) (required)
- WP-CLI associative arguments.
WC_CLI_REST_Command::delete_item() WC CLI REST Command::delete item code WC 9.3.3
public function delete_item( $args, $assoc_args ) { list( $status, $body ) = $this->do_request( 'DELETE', $this->get_filled_route( $args ), $assoc_args ); $object_id = isset( $body['id'] ) ? $body['id'] : ''; if ( ! $object_id && isset( $body['slug'] ) ) { $object_id = $body['slug']; } if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' ) ) { WP_CLI::line( $object_id ); } else { if ( empty( $assoc_args['force'] ) ) { WP_CLI::success( __( 'Trashed', 'woocommerce' ) . " {$this->name} {$object_id}" ); } else { WP_CLI::success( __( 'Deleted', 'woocommerce' ) . " {$this->name} {$object_id}." ); } } }