PHP Класс WC_API_Orders

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

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

Свойство Тип Описание
$base string the route base
$post_type string the custom post type

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

Метод Описание
bulk ( array $data ) : array Bulk update or insert orders Accepts an array with orders in the formats supported by WC_API_Orders->create_order() and WC_API_Orders->edit_order()
create_order ( array $data ) : array Create an order
create_order_note ( string $order_id, array $data ) : WP_Error | array Create a new order note for the given order
create_order_refund ( string $order_id, array $data, boolean $api_refund = true ) : WP_Error | array Create a new order refund for the given order
delete_order ( integer $id, boolean $force = false ) : array Delete an order
delete_order_note ( string $order_id, string $id ) : WP_Error | array Delete order note
delete_order_refund ( string $order_id, string $id ) : WP_Error | array Delete order refund
edit_order ( integer $id, array $data ) : array Edit an order
edit_order_note ( string $order_id, string $id, array $data ) : WP_Error | array Edit the order note
edit_order_refund ( string $order_id, string $id, array $data ) : WP_Error | array Edit an order refund
get_order ( integer $id, array $fields = null ) : array Get the order for the given ID
get_order ( integer $id, array $fields = null, array $filter = [] ) : array Get the order for the given ID.
get_order_note ( string $order_id, string $id, string | null $fields = null ) : array Get an order note for the given order ID and ID
get_order_notes ( integer $id, string $fields = null ) : array Get the admin order notes for an order
get_order_notes ( string $order_id, string | null $fields = null ) : array Get the admin order notes for an order
get_order_refund ( string $order_id, $id, string | null $fields = null ) : array Get an order refund for the given order ID and ID
get_order_refunds ( string $order_id, string | null $fields = null ) : array Get the order refunds for an order
get_order_statuses ( ) : array Get a list of valid order statuses
get_orders ( string $fields = null, array $filter = [], string $status = null, integer $page = 1 ) : array Get all orders
get_orders_count ( string $status = null, array $filter = [] ) : array Get the total number of orders
get_variation_id ( $product, $variations = [] ) : integer Given a product ID & API provided variations, find the correct variation ID to use for calculation We can't just trust input from the API to pass a variation_id manually, otherwise you could pass the cheapest variation ID but provide other information so we have to look up the variation ID.
get_variation_id ( WC_Product $product, $variations = [] ) : integer Given a product ID & API provided variations, find the correct variation ID to use for calculation We can't just trust input from the API to pass a variation_id manually, otherwise you could pass the cheapest variation ID but provide other information so we have to look up the variation ID.
register_routes ( array $routes ) : array Register the routes for this class

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

Метод Описание
array_contains ( $needles, $haystack ) Utility function to see if the meta array contains data from variations
create_base_order ( $args, $data ) : WC_Order Creates new WC_Order.
item_is_null ( array $item ) : boolean Helper method to check if the resource ID associated with the provided item is null
query_orders ( array $args ) : WP_Query Helper method to get order post objects
set_coupon ( WC_Order $order, array $coupon, string $action ) Create or update an order coupon
set_fee ( WC_Order $order, array $fee, string $action ) Create or update an order fee
set_item ( WC_Order $order, string $item_type, array $item, string $action ) Wrapper method to create/update order items
set_line_item ( WC_Order $order, array $item, string $action ) Create or update a line item
set_order_addresses ( WC_Order $order, array $data ) Helper method to set/update the billing & shipping addresses for an order
set_order_meta ( integer $order_id, array $order_meta ) Helper method to add/update order meta, with two restrictions:
set_shipping ( WC_Order $order, array $shipping, string $action ) Create or update an order shipping method
update_address ( WC_Order $order, array $posted, string $type = 'billing' ) Update address.

Приватные методы

Метод Описание
get_order_subtotal ( WC_Order $order ) : float Helper method to get the order subtotal

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

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

Utility function to see if the meta array contains data from variations
protected array_contains ( $needles, $haystack )

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

Bulk update or insert orders Accepts an array with orders in the formats supported by WC_API_Orders->create_order() and WC_API_Orders->edit_order()
С версии: 2.4.0
public bulk ( array $data ) : array
$data array
Результат array

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

Requires a separate function for classes that extend WC_API_Orders.
С версии: 2.3
protected create_base_order ( $args, $data ) : WC_Order
$args array
Результат WC_Order

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

Create an order
С версии: 2.2
public create_order ( array $data ) : array
$data array raw order data
Результат array

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

Create a new order note for the given order
С версии: 2.2
public create_order_note ( string $order_id, array $data ) : WP_Error | array
$order_id string order ID
$data array raw request data
Результат WP_Error | array error or created note response data

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

Create a new order refund for the given order
С версии: 2.2
public create_order_refund ( string $order_id, array $data, boolean $api_refund = true ) : WP_Error | array
$order_id string order ID
$data array raw request data
$api_refund boolean do refund using a payment gateway API
Результат WP_Error | array error or created refund response data

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

Delete an order
public delete_order ( integer $id, boolean $force = false ) : array
$id integer the order ID
$force boolean true to permanently delete order, false to move to trash
Результат array

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

Delete order note
С версии: 2.2
public delete_order_note ( string $order_id, string $id ) : WP_Error | array
$order_id string order ID
$id string note ID
Результат WP_Error | array error or deleted message

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

Delete order refund
С версии: 2.2
public delete_order_refund ( string $order_id, string $id ) : WP_Error | array
$order_id string order ID
$id string refund ID
Результат WP_Error | array error or deleted message

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

Edit an order
С версии: 2.2
public edit_order ( integer $id, array $data ) : array
$id integer the order ID
$data array
Результат array

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

Edit the order note
С версии: 2.2
public edit_order_note ( string $order_id, string $id, array $data ) : WP_Error | array
$order_id string order ID
$id string note ID
$data array parsed request data
Результат WP_Error | array error or edited note response data

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

Edit an order refund
С версии: 2.2
public edit_order_refund ( string $order_id, string $id, array $data ) : WP_Error | array
$order_id string order ID
$id string refund ID
$data array parsed request data
Результат WP_Error | array error or edited refund response data

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

Get the order for the given ID
С версии: 2.1
public get_order ( integer $id, array $fields = null ) : array
$id integer the order ID
$fields array
Результат array

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

Get the order for the given ID.
С версии: 2.1
public get_order ( integer $id, array $fields = null, array $filter = [] ) : array
$id integer The order ID.
$fields array Request fields.
$filter array Request filters.
Результат array

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

Get an order note for the given order ID and ID
С версии: 2.2
public get_order_note ( string $order_id, string $id, string | null $fields = null ) : array
$order_id string order ID
$id string order note ID
$fields string | null fields to limit response to
Результат array

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

Get the admin order notes for an order
С версии: 2.1
public get_order_notes ( integer $id, string $fields = null ) : array
$id integer the order ID
$fields string fields to include in response
Результат array

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

Get the admin order notes for an order
С версии: 2.1
public get_order_notes ( string $order_id, string | null $fields = null ) : array
$order_id string order ID
$fields string | null fields to include in response
Результат array

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

Get an order refund for the given order ID and ID
С версии: 2.2
public get_order_refund ( string $order_id, $id, string | null $fields = null ) : array
$order_id string order ID
$fields string | null fields to limit response to
Результат array

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

Get the order refunds for an order
С версии: 2.2
public get_order_refunds ( string $order_id, string | null $fields = null ) : array
$order_id string order ID
$fields string | null fields to include in response
Результат array

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

Note this requires no specific permissions other than being an authenticated API user. Order statuses (particularly custom statuses) could be considered private information which is why it's not in the API index.
С версии: 2.1
public get_order_statuses ( ) : array
Результат array

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

Get all orders
С версии: 2.1
public get_orders ( string $fields = null, array $filter = [], string $status = null, integer $page = 1 ) : array
$fields string
$filter array
$status string
$page integer
Результат array

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

Get the total number of orders
С версии: 2.4
public get_orders_count ( string $status = null, array $filter = [] ) : array
$status string
$filter array
Результат array

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

Given a product ID & API provided variations, find the correct variation ID to use for calculation We can't just trust input from the API to pass a variation_id manually, otherwise you could pass the cheapest variation ID but provide other information so we have to look up the variation ID.
public get_variation_id ( $product, $variations = [] ) : integer
Результат integer returns an ID if a valid variation was found for this product

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

Given a product ID & API provided variations, find the correct variation ID to use for calculation We can't just trust input from the API to pass a variation_id manually, otherwise you could pass the cheapest variation ID but provide other information so we have to look up the variation ID.
public get_variation_id ( WC_Product $product, $variations = [] ) : integer
$product WC_Product Product instance
Результат integer Returns an ID if a valid variation was found for this product

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

Items can be deleted by setting the resource ID to null
С версии: 2.2
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

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

Helper method to get order post objects
С версии: 2.1
protected query_orders ( array $args ) : WP_Query
$args array request arguments for filtering query
Результат WP_Query

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

GET|POST /orders GET /orders/count GET|PUT|DELETE /orders/ GET /orders//notes
С версии: 2.1
public register_routes ( array $routes ) : array
$routes array
Результат array

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

Create or update an order coupon
С версии: 2.2
protected set_coupon ( WC_Order $order, array $coupon, string $action )
$order WC_Order
$coupon array item data
$action string 'create' to add coupon or 'update' to update it

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

Create or update an order fee
С версии: 2.2
protected set_fee ( WC_Order $order, array $fee, string $action )
$order WC_Order
$fee array item data
$action string 'create' to add fee or 'update' to update it

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

When updating, the item ID provided is checked to ensure it is associated with the order.
С версии: 2.2
protected set_item ( WC_Order $order, string $item_type, array $item, string $action )
$order WC_Order order
$item_type string
$item array item provided in the request body
$action string either 'create' or 'update'

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

Create or update a line item
С версии: 2.2
protected set_line_item ( WC_Order $order, array $item, string $action )
$order WC_Order
$item array line item data
$action string 'create' to add line item or 'update' to update it

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

Helper method to set/update the billing & shipping addresses for an order
С версии: 2.1
protected set_order_addresses ( WC_Order $order, array $data )
$order WC_Order
$data array

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

1) Only non-protected meta (no leading underscore) can be set 2) Meta values must be scalar (int, string, bool)
С версии: 2.2
protected set_order_meta ( integer $order_id, array $order_meta )
$order_id integer valid order ID
$order_meta array order meta in array( 'meta_key' => 'meta_value' ) format

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

Create or update an order shipping method
С версии: 2.2
protected set_shipping ( WC_Order $order, array $shipping, string $action )
$order WC_Order
$shipping array item data
$action string 'create' to add shipping or 'update' to update it

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

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

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

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

the route base
protected string $base
Результат string

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

the custom post type
protected string $post_type
Результат string