Property | Type | Description | |
---|---|---|---|
$namespace | string | Endpoint namespace. | |
$post_type | string | Post type. | |
$request | array | Stores the request. | |
$rest_base | string | Route base. |
Method | Description | |
---|---|---|
__construct ( ) | Initialize orders 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. | |
get_item_schema ( ) : array | Get the Order's schema, conforming to JSON Schema. | |
prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response | Prepare a single order output for response. | |
query_args ( array $args, WP_REST_Request $request ) : array | Query args. | |
register_routes ( ) | Register the routes for orders. | |
update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response | Update a single order. |
Method | Description | |
---|---|---|
create_base_order ( array $data ) : WC_Order | Create base WC Order object. | |
create_order ( WP_REST_Request $request ) : integer | WP_Error | Create order. | |
filter_writable_props ( array $schema ) : boolean | Only reutrn writeable props from schema. | |
get_order_item_data ( WC_Order_item $item ) : array | Expands an order item to get its data. | |
get_order_statuses ( ) : array | Get order statuses without prefixes. | |
get_product_id ( array $posted ) : integer | Gets the product ID from the SKU or posted ID. | |
item_is_null ( array $item ) : boolean | Helper method to check if the resource ID associated with the provided item is null. | |
maybe_set_item_prop ( WC_Order_Item $item, string $prop, array $posted ) | Maybe set an item prop if the value was posted. | |
maybe_set_item_props ( WC_Order_Item $item, string[] $props, array $posted ) | Maybe set item props if the values were posted. | |
prepare_coupon_lines ( array $posted, string $action ) | Create or update an order coupon. | |
prepare_fee_lines ( array $posted, string $action ) | Create or update an order fee. | |
prepare_item_for_database ( WP_REST_Request $request ) : WP_Error | WC_Order | Prepare a single order for create. | |
prepare_line_items ( array $posted, string $action = 'create' ) | Create or update a line item. | |
prepare_links ( WC_Order $order, WP_REST_Request $request ) : array | Prepare links for the request. | |
prepare_shipping_lines ( $posted, string $action ) | Create or update an order shipping method. | |
set_item ( WC_Order $order, string $item_type, array $posted ) | Wrapper method to create/update order items. | |
update_address ( WC_Order $order, array $posted, string $type = 'billing' ) | Update address. | |
update_order ( WP_REST_Request $request ) : integer | WP_Error | Update order. |
protected create_base_order ( array $data ) : WC_Order | ||
$data | array | |
return | WC_Order |
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 |
protected create_order ( WP_REST_Request $request ) : integer | WP_Error | ||
$request | WP_REST_Request | Full details about the request. |
return | integer | WP_Error |
protected filter_writable_props ( array $schema ) : boolean | ||
$schema | array | |
return | boolean |
public get_collection_params ( ) : array | ||
return | array |
public get_item_schema ( ) : array | ||
return | array |
protected get_order_item_data ( WC_Order_item $item ) : array | ||
$item | WC_Order_item | |
return | array |
protected get_order_statuses ( ) : array | ||
return | array |
protected get_product_id ( array $posted ) : integer | ||
$posted | array | Request data |
return | integer |
protected item_is_null ( array $item ) : boolean | ||
$item | array | Item provided in the request body. |
return | boolean | True if the item resource ID is null, false otherwise. |
protected maybe_set_item_prop ( WC_Order_Item $item, string $prop, array $posted ) | ||
$item | WC_Order_Item | |
$prop | string | |
$posted | array | Request data. |
protected maybe_set_item_props ( WC_Order_Item $item, string[] $props, array $posted ) | ||
$item | WC_Order_Item | |
$props | string[] | |
$posted | array | Request data. |
protected prepare_coupon_lines ( array $posted, string $action ) | ||
$posted | array | Item data. |
$action | string | 'create' to add coupon or 'update' to update it. |
protected prepare_fee_lines ( array $posted, string $action ) | ||
$posted | array | Item data. |
$action | string | 'create' to add fee or 'update' to update it. |
protected prepare_item_for_database ( WP_REST_Request $request ) : WP_Error | WC_Order | ||
$request | WP_REST_Request | Request object. |
return | WP_Error | WC_Order | $data Object. |
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 |
protected prepare_line_items ( array $posted, string $action = 'create' ) | ||
$posted | array | Line item data. |
$action | string | 'create' to add line item or 'update' to update it. |
protected prepare_links ( WC_Order $order, WP_REST_Request $request ) : array | ||
$order | WC_Order | Order object. |
$request | WP_REST_Request | Request object. |
return | array | Links for the given order. |
protected prepare_shipping_lines ( $posted, string $action ) | ||
$posted | $shipping Item data. | |
$action | string | 'create' to add shipping or 'update' to update it. |
public query_args ( array $args, WP_REST_Request $request ) : array | ||
$args | array | |
$request | WP_REST_Request | |
return | array |
protected update_address ( WC_Order $order, array $posted, string $type = 'billing' ) | ||
$order | WC_Order | |
$posted | array | |
$type | string |
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 |
protected update_order ( WP_REST_Request $request ) : integer | WP_Error | ||
$request | WP_REST_Request | Full details about the request. |
return | integer | WP_Error |