WC_API_Coupons::register_routes()
Register the routes for this class
GET /coupons GET /coupons/count GET /coupons/<id>
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. |
WC_API_Coupons::register_routes() WC API Coupons::register routes code WC 7.7.0
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; }