WC_CLI_REST_Command::create_item()publicWC 1.0

Create a new 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->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() code WC 8.7.0

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']}." );
	}
}