WC_REST_Order_Refunds_Controller::add_cogs_related_schema
Add the Cost of Goods Sold related fields to the schema.
Method of the class: WC_REST_Order_Refunds_Controller{}
No Hooks.
Returns
Array. The updated schema.
Usage
// private - for code of main (parent) class only $result = $this->add_cogs_related_schema( $schema ): array;
- $schema(array) (required)
- The original schema.
WC_REST_Order_Refunds_Controller::add_cogs_related_schema() WC REST Order Refunds Controller::add cogs related schema code WC 10.3.6
private function add_cogs_related_schema( array $schema ): array {
$schema['properties']['cost_of_goods_sold'] = array(
'description' => __( 'Cost of Goods Sold data.', 'woocommerce' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'total_value' => array(
'description' => __( 'Total value of the Cost of Goods Sold for the refund.', 'woocommerce' ),
'type' => 'number',
'readonly' => true,
'context' => array( 'view', 'edit' ),
),
),
);
$schema['properties']['line_items']['items']['properties']['cost_of_goods_sold'] = array(
'description' => __( 'Cost of Goods Sold data. Only present for product refund line items.', 'woocommerce' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'properties' => array(
'total_value' => array(
'description' => __( 'Value of the Cost of Goods Sold for the refund item.', 'woocommerce' ),
'type' => 'number',
'readonly' => true,
'context' => array( 'view', 'edit' ),
),
),
);
return $schema;
}