Automattic\WooCommerce\Internal\RestApi\Routes\V4\Refunds\Schema
RefundSchema::get_item_schema_properties │ public │ WC 1.0
Return all properties for the item schema.
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.
Method of the class: RefundSchema{}
No Hooks.
Returns
Array.
Usage
$RefundSchema = new RefundSchema(); $RefundSchema->get_item_schema_properties(): array;
RefundSchema::get_item_schema_properties() RefundSchema::get item schema properties code WC 11.0.1
public function get_item_schema_properties(): array {
$schema = array(
'id' => array(
'description' => __( 'Unique identifier for the refund.', 'woocommerce' ),
'type' => 'integer',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'order_id' => array(
'description' => __( 'The ID of the order that was refunded.', 'woocommerce' ),
'type' => 'integer',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'required' => true,
'sanitize_callback' => 'absint',
),
'amount' => array(
'description' => __( 'Amount that was refunded. This is calculated from the line items if not provided.', 'woocommerce' ),
'type' => 'number',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'default' => 0,
'sanitize_callback' => 'sanitize_text_field',
'validate_callback' => 'rest_validate_request_arg',
),
'reason' => array(
'description' => __( 'Reason for the refund.', 'woocommerce' ),
'type' => 'string',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'default' => '',
'sanitize_callback' => 'sanitize_text_field',
),
'currency' => array(
'description' => __( 'Currency the refund was created with, in ISO format.', 'woocommerce' ),
'type' => 'string',
'default' => get_woocommerce_currency(),
'enum' => array_keys( get_woocommerce_currencies() ),
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'currency_symbol' => array(
'description' => __( 'Currency symbol for the currency which can be used to format returned prices.', 'woocommerce' ),
'type' => 'string',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'date_created' => array(
'description' => __( "The date the refund was created, in the site's timezone.", 'woocommerce' ),
'type' => 'string',
'format' => 'date-time',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'date_created_gmt' => array(
'description' => __( 'The date the refund was created, as GMT.', 'woocommerce' ),
'type' => 'string',
'format' => 'date-time',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'refunded_by' => array(
'description' => __( 'User who created the refund.', 'woocommerce' ),
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'User ID of user who created the refund.', 'woocommerce' ),
'type' => 'integer',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'display_name' => array(
'description' => __( 'Display name of the user who created the refund.', 'woocommerce' ),
'type' => 'string',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'avatar_url' => array(
'description' => __( 'Avatar URL of the user who created the refund.', 'woocommerce' ),
'type' => 'string',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
'format' => 'uri',
),
),
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'refunded_payment' => array(
'description' => __( 'If the payment was refunded via the API.', 'woocommerce' ),
'type' => 'boolean',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'meta_data' => array(
'description' => __( 'Meta data.', 'woocommerce' ),
'type' => 'array',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
'items' => array(
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'Meta ID.', 'woocommerce' ),
'type' => 'integer',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'key' => array(
'description' => __( 'Meta key.', 'woocommerce' ),
'type' => 'string',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
),
'value' => array(
'description' => __( 'Meta value.', 'woocommerce' ),
'type' => array( 'null', 'object', 'string', 'number', 'boolean', 'integer', 'array' ),
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
),
),
),
),
'line_items' => array(
'description' => __( 'Refunded line items. This can include products, fees, and shipping lines, combined into a single array.', 'woocommerce' ),
'type' => 'array',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'default' => array(),
'items' => array(
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'ID of the refund line item. This is not the ID of the original line item.', 'woocommerce' ),
'type' => 'integer',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'readonly' => true,
),
'line_item_id' => array(
'description' => __( 'ID of the original line item.', 'woocommerce' ),
'type' => 'integer',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'required' => true,
'sanitize_callback' => 'absint',
'validate_callback' => 'rest_validate_request_arg',
),
'quantity' => array(
'description' => __( 'Quantity refunded. Required when refund_total is omitted (the backend computes the total from unit price × quantity); optional when refund_total is provided explicitly.', 'woocommerce' ),
'type' => 'integer',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'sanitize_callback' => 'wc_stock_amount',
'validate_callback' => 'rest_validate_request_arg',
),
'refund_total' => array(
'description' => __( 'Optional: Total refunded for this item. Tax-inclusive when refund_tax is omitted (the backend splits out tax automatically); tax-exclusive (net subtotal) when refund_tax is supplied, in which case the line\'s total refund is refund_total + refund_tax. If omitted or set to null, the backend computes it from the order line item\'s unit price multiplied by quantity. A gross line refund that rounds to 0 is rejected.', 'woocommerce' ),
'type' => array( 'number', 'null' ),
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'validate_callback' => 'rest_validate_request_arg',
),
'refund_tax' => array(
'description' => __( 'Optional: Taxes refunded for this item. If not provided, tax is automatically split out of the tax-inclusive refund_total using the line\'s own stored total-to-tax ratio (what was charged), not the order\'s current tax rates. When provided, refund_total is treated as the tax-exclusive subtotal and these taxes are added on top.', 'woocommerce' ),
'type' => 'array',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'default' => array(),
'items' => array(
'type' => 'object',
'properties' => array(
'id' => array(
'description' => __( 'Tax ID.', 'woocommerce' ),
'type' => 'integer',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'required' => true,
'sanitize_callback' => 'absint',
'validate_callback' => 'rest_validate_request_arg',
),
'refund_total' => array(
'description' => __( 'Amount refunded for this tax.', 'woocommerce' ),
'type' => 'number',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'required' => true,
'sanitize_callback' => 'sanitize_text_field',
'validate_callback' => 'rest_validate_request_arg',
),
),
),
),
),
),
),
);
if ( $this->cogs_is_enabled() ) {
$schema = $this->add_cogs_related_schema( $schema );
}
return $schema;
}