Automattic\WooCommerce\Internal\RestApi\Routes\V4\Refunds\Schema

RefundPreviewSchema::get_section_schemaprivateWC 1.0

Schema for one section of the breakdown (products, shipping, or fees).

Method of the class: RefundPreviewSchema{}

No Hooks.

Returns

Array.

Usage

// private - for code of main (parent) class only
$result = $this->get_section_schema( $section_key ): array;
$section_key(string) (required)
One of 'products', 'shipping', 'fees'. Determines which item schema variant is used.

RefundPreviewSchema::get_section_schema() code WC 11.0.1

private function get_section_schema( string $section_key ): array {
	return array(
		'type'       => 'object',
		'properties' => array(
			'items'    => array(
				'description' => __( 'Line items in this section.', 'woocommerce' ),
				'type'        => 'array',
				'items'       => 'products' === $section_key ? $this->get_product_item_schema() : $this->get_base_item_schema(),
				'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				'readonly'    => true,
			),
			'subtotal' => array(
				'description' => __( 'Section subtotal (excluding tax).', 'woocommerce' ),
				'type'        => 'string',
				'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				'readonly'    => true,
			),
			'tax'      => array(
				'description' => __( 'Section tax total.', 'woocommerce' ),
				'type'        => 'string',
				'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				'readonly'    => true,
			),
			'total'    => array(
				'description' => __( 'Section total (tax-inclusive).', 'woocommerce' ),
				'type'        => 'string',
				'context'     => self::VIEW_EDIT_EMBED_CONTEXT,
				'readonly'    => true,
			),
		),
	);
}