PHP Class WC_REST_Product_Variations_Controller

Inheritance: extends WC_REST_Products_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 ( ) Initialize product actions (parent).
add_product_id ( array $args, WP_REST_Request $request ) : array Adds the parent product ID to the query so we filter / get the correct variations.
batch_items ( WP_REST_Request $request ) : array Bulk create, update and delete items.
delete_item ( WP_REST_Request $request ) : WP_Error | boolean Delete a variation.
get_item_schema ( ) : array Get the Variation's schema, conforming to JSON Schema.
prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response Prepare a single variation output for response.
register_routes ( ) Register the routes for products.

Protected Methods

Method Description
add_post_meta_fields ( WP_Post $post, WP_REST_Request $request ) : boolean | WP_Error Add post meta fields.
prepare_item_for_database ( WP_REST_Request $request ) : WP_Error | stdClass Prepare a single variation for create or update.
prepare_links ( $variation, WP_REST_Request $request ) : array Prepare links for the request.
update_post_meta_fields ( WP_Post $post, WP_REST_Request $request ) : boolean | WP_Error Update post meta fields.

Method Details

__construct() public method

Initialize product actions (parent).
public __construct ( )

add_post_meta_fields() protected method

Add post meta fields.
protected add_post_meta_fields ( WP_Post $post, WP_REST_Request $request ) : boolean | WP_Error
$post WP_Post
$request WP_REST_Request
return boolean | WP_Error

add_product_id() public method

Adds the parent product ID to the query so we filter / get the correct variations.
public add_product_id ( array $args, WP_REST_Request $request ) : array
$args array
$request WP_REST_Request
return array

batch_items() public method

Bulk create, update and delete items.
Since: 2.7.0
public batch_items ( WP_REST_Request $request ) : array
$request WP_REST_Request Full details about the request.
return array Of WP_Error or WP_REST_Response.

delete_item() public method

Delete a variation.
public delete_item ( WP_REST_Request $request ) : WP_Error | boolean
$request WP_REST_Request Full details about the request
return WP_Error | boolean

get_item_schema() public method

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

prepare_item_for_database() protected method

Prepare a single variation 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 variation 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

register_routes() public method

Register the routes for products.
public register_routes ( )

update_post_meta_fields() protected method

Update post meta fields.
protected update_post_meta_fields ( WP_Post $post, WP_REST_Request $request ) : boolean | WP_Error
$post WP_Post
$request WP_REST_Request
return boolean | WP_Error

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