PHP Class WC_REST_Coupons_Controller

Inheritance: extends WC_REST_Posts_Controller
Show file Open project: woocommerce/woocommerce

Protected Properties

Property Type Description
$namespace string Endpoint namespace.
$post_type string Post type.
$rest_base string Route base.

Public Methods

Method Description
__construct ( ) Order refunds actions.
create_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response Create a single item.
get_collection_params ( ) : array Get the query params for collections of attachments.
get_item_schema ( ) : array Get the Coupon's schema, conforming to JSON Schema.
prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response Prepare a single coupon output for response.
query_args ( array $args, WP_REST_Request $request ) : array Query args.
register_routes ( ) Register the routes for coupons.
save_coupon ( $request ) Saves a coupon to the database.
update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response Update a single coupon.

Protected Methods

Method Description
filter_writable_props ( array $schema ) : boolean Only reutrn writeable props from schema.
prepare_item_for_database ( WP_REST_Request $request ) : WP_Error | stdClass Prepare a single coupon for create or update.

Method Details

__construct() public method

Order refunds actions.
public __construct ( )

create_item() public method

Create a single item.
public create_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
return WP_Error | WP_REST_Response

filter_writable_props() protected method

Only reutrn writeable props from schema.
protected filter_writable_props ( array $schema ) : boolean
$schema array
return boolean

get_collection_params() public method

Get the query params for collections of attachments.
public get_collection_params ( ) : array
return array

get_item_schema() public method

Get the Coupon's schema, conforming to JSON Schema.
public get_item_schema ( ) : array
return array

prepare_item_for_database() protected method

Prepare a single coupon for create or update.
protected prepare_item_for_database ( WP_REST_Request $request ) : WP_Error | stdClass
$request WP_REST_Request Request object.
return WP_Error | stdClass $data Post object.

prepare_item_for_response() public method

Prepare a single coupon output for response.
public prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response
$post WP_Post Post object.
$request WP_REST_Request Request object.
return WP_REST_Response $data

query_args() public method

Query args.
public query_args ( array $args, WP_REST_Request $request ) : array
$args array
$request WP_REST_Request
return array

register_routes() public method

Register the routes for coupons.
public register_routes ( )

save_coupon() public method

Saves a coupon to the database.
public save_coupon ( $request )

update_item() public method

Update a single coupon.
public update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
return WP_Error | WP_REST_Response

Property Details

$namespace protected property

Endpoint namespace.
protected string $namespace
return string

$post_type protected property

Post type.
protected string $post_type
return string

$rest_base protected property

Route base.
protected string $rest_base
return string