OrderSchema
extends AbstractSchema
in package
Uses
CogsAwareTrait
OrderSchema class.
Table of Contents
- IDENTIFIER = 'order'
- The schema item identifier.
- VIEW_EDIT_CONTEXT = array('view', 'edit')
- Context for the item schema - view and edit only.
- VIEW_EDIT_EMBED_CONTEXT = array('view', 'edit', 'embed')
- Context for the item schema - view, edit, and embed.
- $order_coupon_schema : OrderCouponSchema
- The order coupon schema.
- $order_fee_schema : OrderFeeSchema
- The order fee schema.
- $order_item_schema : OrderItemSchema
- The order item schema.
- $order_shipping_schema : OrderShippingSchema
- The order shipping schema.
- $order_tax_schema : OrderTaxSchema
- The order tax schema.
- get_item_response() : array<string|int, mixed>
- Get an item response.
- get_item_schema() : array<string|int, mixed>
- Get the item schema.
- get_item_schema_properties() : array<string|int, mixed>
- Return all properties for the item schema.
- get_writable_item_schema_properties() : array<string|int, mixed>
- Return all writable properties for the item schema.
- filter_internal_meta_keys() : array<string|int, mixed>
- With HPOS, few internal meta keys such as _billing_address_index, _shipping_address_index are not considered internal anymore (since most internal keys were flattened into dedicated columns).
- filter_writable_props() : bool
- Filter schema properties to only return writable ones.
- get_meta_data_for_response() : array<string|int, mixed>
- Limit the contents of the meta_data property based on certain request parameters.
- add_cogs_related_schema() : array<string|int, mixed>
- Add the Cost of Goods Sold related fields to the schema.
Constants
IDENTIFIER
The schema item identifier.
public
string
IDENTIFIER
= 'order'
VIEW_EDIT_CONTEXT
Context for the item schema - view and edit only.
public
array<string|int, mixed>
VIEW_EDIT_CONTEXT
= array('view', 'edit')
Tags
VIEW_EDIT_EMBED_CONTEXT
Context for the item schema - view, edit, and embed.
public
array<string|int, mixed>
VIEW_EDIT_EMBED_CONTEXT
= array('view', 'edit', 'embed')
Tags
Properties
$order_coupon_schema
The order coupon schema.
private
OrderCouponSchema
$order_coupon_schema
$order_fee_schema
The order fee schema.
private
OrderFeeSchema
$order_fee_schema
$order_item_schema
The order item schema.
private
OrderItemSchema
$order_item_schema
$order_shipping_schema
The order shipping schema.
private
OrderShippingSchema
$order_shipping_schema
$order_tax_schema
The order tax schema.
private
OrderTaxSchema
$order_tax_schema
Methods
get_item_response()
Get an item response.
public
get_item_response(WC_Order $order, WP_REST_Request $request[, array<string|int, mixed> $include_fields = array() ]) : array<string|int, mixed>
Parameters
- $order : WC_Order
-
Order instance.
- $request : WP_REST_Request
-
Request object.
- $include_fields : array<string|int, mixed> = array()
-
Fields to include in the response.
Return values
array<string|int, mixed> —get_item_schema()
Get the item schema.
public
get_item_schema() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> — The item schema.get_item_schema_properties()
Return all properties for the item schema.
public
get_item_schema_properties() : array<string|int, mixed>
Note that context determines under which context data should be visible. For example, edit would be the context used when getting records with the intent of editing them. embed context allows the data to be visible when the item is being embedded in another response.
Return values
array<string|int, mixed> —get_writable_item_schema_properties()
Return all writable properties for the item schema.
public
get_writable_item_schema_properties() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> — The schema properties.filter_internal_meta_keys()
With HPOS, few internal meta keys such as _billing_address_index, _shipping_address_index are not considered internal anymore (since most internal keys were flattened into dedicated columns).
protected
filter_internal_meta_keys(array<string|int, mixed> $meta_data) : array<string|int, mixed>
This function helps in filtering out any remaining internal meta keys with HPOS is enabled.
Parameters
- $meta_data : array<string|int, mixed>
-
Order meta data.
Return values
array<string|int, mixed> — Filtered order meta data.filter_writable_props()
Filter schema properties to only return writable ones.
protected
filter_writable_props(array<string|int, mixed> $schema) : bool
Parameters
- $schema : array<string|int, mixed>
-
The schema property to check.
Tags
Return values
bool — True if the property is writable, false otherwise.get_meta_data_for_response()
Limit the contents of the meta_data property based on certain request parameters.
protected
get_meta_data_for_response(array<string|int, mixed> $meta_data, WP_REST_Request $request) : array<string|int, mixed>
Note that if both include_meta and exclude_meta are present in the request,
include_meta will take precedence.
Parameters
- $meta_data : array<string|int, mixed>
-
All of the meta data for an object.
- $request : WP_REST_Request
-
The request.
Return values
array<string|int, mixed> —add_cogs_related_schema()
Add the Cost of Goods Sold related fields to the schema.
private
static add_cogs_related_schema(array<string|int, mixed> $schema) : array<string|int, mixed>
Parameters
- $schema : array<string|int, mixed>
-
The original schema.
