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 10.4.3
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 ID of user who created the refund.', 'woocommerce' ),
'type' => 'integer',
'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.', 'woocommerce' ),
'type' => 'integer',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'default' => 0,
'sanitize_callback' => 'wc_stock_amount',
'validate_callback' => 'rest_validate_request_arg',
),
'refund_total' => array(
'description' => __( 'Total refunded for this item.', 'woocommerce' ),
'type' => 'number',
'context' => self::VIEW_EDIT_EMBED_CONTEXT,
'default' => 0,
'sanitize_callback' => 'sanitize_text_field',
'validate_callback' => 'rest_validate_request_arg',
),
'refund_tax' => array(
'description' => __( 'Taxes refunded for this item.', '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;
}