WooCommerce Code Reference

OrderFeeSchema extends AbstractLineItemSchema
in package

OrderFeeSchema class.

Table of Contents

IDENTIFIER  = 'order-fee'
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.
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_writable_props()  : bool
Filter schema properties to only return writable ones.
get_meta_data_schema()  : array<string|int, mixed>
Get the meta data schema shared by all line item schemas.
get_taxes_schema()  : array<string|int, mixed>
Get the taxes schema shared by line item schemas.
prepare_meta_data()  : array<string|int, mixed>
Prepare the meta data for the order item.
prepare_taxes()  : array<string|int, mixed>
Prepare the taxes for the order item.

Constants

VIEW_EDIT_CONTEXT

Context for the item schema - view and edit only.

public array<string|int, mixed> VIEW_EDIT_CONTEXT = array('view', 'edit')
Tags
since
10.2.0

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
since
10.2.0

Methods

get_item_response()

Get an item response.

public get_item_response(WC_Order_Item_Fee $order_item, WP_REST_Request $request[, array<string|int, mixed> $include_fields = array() ]) : array<string|int, mixed>
Parameters
$order_item : WC_Order_Item_Fee

Order item 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
since
10.2.0
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
since
10.2.0
Return values
array<string|int, mixed>The schema properties.

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
since
10.2.0
Return values
boolTrue if the property is writable, false otherwise.

prepare_taxes()

Prepare the taxes for the order item.

protected prepare_taxes(WC_Order_Item_Product|WC_Order_Item_Fee $order_item, WP_REST_Request $request) : array<string|int, mixed>
Parameters
$order_item : WC_Order_Item_Product|WC_Order_Item_Fee

Order item instance.

$request : WP_REST_Request

Request object.

Return values
array<string|int, mixed>