WC_CLI_REST_Command::create_item
Create a new item.
Method of the class: WC_CLI_REST_Command{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_CLI_REST_Command = new WC_CLI_REST_Command(); $WC_CLI_REST_Command->create_item( $args, $assoc_args );
- $args(array) (required)
- WP-CLI positional arguments.
- $assoc_args(array) (required)
- WP-CLI associative arguments.
WC_CLI_REST_Command::create_item() WC CLI REST Command::create item code WC 10.6.2
public function create_item( $args, $assoc_args ) {
$assoc_args = self::decode_json( $assoc_args );
list( $status, $body ) = $this->do_request( 'POST', $this->get_filled_route( $args ), $assoc_args );
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' ) ) {
WP_CLI::line( $body['id'] );
} else {
WP_CLI::success( "Created {$this->name} {$body['id']}." );
}
}