PHP Класс WC_REST_Orders_Controller

Наследование: extends WC_REST_Posts_Controller
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$namespace string Endpoint namespace.
$post_type string Post type.
$request array Stores the request.
$rest_base string Route base.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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.

Описание методов

__construct() публичный Метод

Initialize orders actions.
public __construct ( )

create_base_order() защищенный Метод

Create base WC Order object.
Устаревший: 2.7.0
protected create_base_order ( array $data ) : WC_Order
$data array
Результат WC_Order

create_item() публичный Метод

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.
Результат WP_Error | WP_REST_Response

create_order() защищенный Метод

Create order.
protected create_order ( WP_REST_Request $request ) : integer | WP_Error
$request WP_REST_Request Full details about the request.
Результат integer | WP_Error

filter_writable_props() защищенный Метод

Only reutrn writeable props from schema.
protected filter_writable_props ( array $schema ) : boolean
$schema array
Результат boolean

get_collection_params() публичный Метод

Get the query params for collections.
public get_collection_params ( ) : array
Результат array

get_item_schema() публичный Метод

Get the Order's schema, conforming to JSON Schema.
public get_item_schema ( ) : array
Результат array

get_order_item_data() защищенный Метод

Expands an order item to get its data.
protected get_order_item_data ( WC_Order_item $item ) : array
$item WC_Order_item
Результат array

get_order_statuses() защищенный Метод

Get order statuses without prefixes.
protected get_order_statuses ( ) : array
Результат array

get_product_id() защищенный Метод

Gets the product ID from the SKU or posted ID.
protected get_product_id ( array $posted ) : integer
$posted array Request data
Результат integer

item_is_null() защищенный Метод

Items can be deleted by setting the resource ID to null.
protected item_is_null ( array $item ) : boolean
$item array Item provided in the request body.
Результат boolean True if the item resource ID is null, false otherwise.

maybe_set_item_prop() защищенный Метод

Maybe set an item prop if the value was posted.
protected maybe_set_item_prop ( WC_Order_Item $item, string $prop, array $posted )
$item WC_Order_Item
$prop string
$posted array Request data.

maybe_set_item_props() защищенный Метод

Maybe set item props if the values were posted.
protected maybe_set_item_props ( WC_Order_Item $item, string[] $props, array $posted )
$item WC_Order_Item
$props string[]
$posted array Request data.

prepare_coupon_lines() защищенный Метод

Create or update an order coupon.
protected prepare_coupon_lines ( array $posted, string $action )
$posted array Item data.
$action string 'create' to add coupon or 'update' to update it.

prepare_fee_lines() защищенный Метод

Create or update an order fee.
protected prepare_fee_lines ( array $posted, string $action )
$posted array Item data.
$action string 'create' to add fee or 'update' to update it.

prepare_item_for_database() защищенный Метод

Prepare a single order for create.
protected prepare_item_for_database ( WP_REST_Request $request ) : WP_Error | WC_Order
$request WP_REST_Request Request object.
Результат WP_Error | WC_Order $data Object.

prepare_item_for_response() публичный Метод

Prepare a single order 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.
Результат WP_REST_Response $data

prepare_line_items() защищенный Метод

Create or update a line item.
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.

prepare_shipping_lines() защищенный Метод

Create or update an order shipping method.
protected prepare_shipping_lines ( $posted, string $action )
$posted $shipping Item data.
$action string 'create' to add shipping or 'update' to update it.

query_args() публичный Метод

Query args.
public query_args ( array $args, WP_REST_Request $request ) : array
$args array
$request WP_REST_Request
Результат array

register_routes() публичный Метод

Register the routes for orders.
public register_routes ( )

set_item() защищенный Метод

When updating, the item ID provided is checked to ensure it is associated with the order.
protected set_item ( WC_Order $order, string $item_type, array $posted )
$order WC_Order order
$item_type string
$posted array item provided in the request body

update_address() защищенный Метод

Update address.
protected update_address ( WC_Order $order, array $posted, string $type = 'billing' )
$order WC_Order
$posted array
$type string

update_item() публичный Метод

Update a single order.
public update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Результат WP_Error | WP_REST_Response

update_order() защищенный Метод

Update order.
protected update_order ( WP_REST_Request $request ) : integer | WP_Error
$request WP_REST_Request Full details about the request.
Результат integer | WP_Error

Описание свойств

$namespace защищенное свойство

Endpoint namespace.
protected string $namespace
Результат string

$post_type защищенное свойство

Post type.
protected string $post_type
Результат string

$request защищенное свойство

Stores the request.
protected array $request
Результат array

$rest_base защищенное свойство

Route base.
protected string $rest_base
Результат string