WC_API_Coupons::register_routes()publicWC 2.1

Register the routes for this class

GET /coupons GET /coupons/count GET /coupons/<id>

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

Хуков нет.

Возвращает

Массив.

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

$WC_API_Coupons = new WC_API_Coupons();
$WC_API_Coupons->register_routes( $routes );
$routes(массив) (обязательный)
-

Список изменений

С версии 2.1 Введена.

Код WC_API_Coupons::register_routes() WC 8.7.0

public function register_routes( $routes ) {

	# GET/POST /coupons
	$routes[ $this->base ] = array(
		array( array( $this, 'get_coupons' ),     WC_API_Server::READABLE ),
		array( array( $this, 'create_coupon' ),   WC_API_Server::CREATABLE | WC_API_Server::ACCEPT_DATA ),
	);

	# GET /coupons/count
	$routes[ $this->base . '/count' ] = array(
		array( array( $this, 'get_coupons_count' ), WC_API_Server::READABLE ),
	);

	# GET/PUT/DELETE /coupons/<id>
	$routes[ $this->base . '/(?P<id>\d+)' ] = array(
		array( array( $this, 'get_coupon' ),    WC_API_Server::READABLE ),
		array( array( $this, 'edit_coupon' ),   WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ),
		array( array( $this, 'delete_coupon' ), WC_API_Server::DELETABLE ),
	);

	# GET /coupons/code/<code>, note that coupon codes can contain spaces, dashes and underscores
	$routes[ $this->base . '/code/(?P<code>\w[\w\s\-]*)' ] = array(
		array( array( $this, 'get_coupon_by_code' ), WC_API_Server::READABLE ),
	);

	# POST|PUT /coupons/bulk
	$routes[ $this->base . '/bulk' ] = array(
		array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ),
	);

	return $routes;
}