WordPress at Your Fingertips
function is not described

WC_API_Coupons::register_routes() public WC 2.1

Register the routes for this class

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

{} It's a method of the class: WC_API_Coupons{}

No Hooks.

Return

Array.

Usage

$WC_API_Coupons = new WC_API_Coupons();
$WC_API_Coupons->register_routes( $routes );
$routes(array) (required)
-

Changelog

Since 2.1 Introduced.

Code of WC_API_Coupons::register_routes() WC 5.7.1

public function register_routes( $routes ) {

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

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

	# GET /coupons/<id>
	$routes[ $this->base . '/(?P<id>\d+)' ] = array(
		array( array( $this, 'get_coupon' ),  WC_API_Server::READABLE ),
	);

	# 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 ),
	);

	return $routes;
}