WC_CLI_REST_Command::create_item()publicWC 1.0

Create a new item.

Метод класса: WC_CLI_REST_Command{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WC_CLI_REST_Command = new WC_CLI_REST_Command();
$WC_CLI_REST_Command->create_item( $args, $assoc_args );
$args(массив) (обязательный)
WP-CLI positional arguments.
$assoc_args(массив) (обязательный)
WP-CLI associative arguments.

Код WC_CLI_REST_Command::create_item() 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']}." );
	}
}