WC_REST_Orders_Controller::add_cogs_related_schema()
Add the Cost of Goods Sold related fields to the schema.
Method of the class: WC_REST_Orders_Controller{}
No Hooks.
Return
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_Orders_Controller::add_cogs_related_schema() WC REST Orders Controller::add cogs related schema code WC 9.5.1
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 order.', '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 line items.', 'woocommerce' ), 'type' => 'object', 'context' => array( 'view', 'edit' ), 'properties' => array( 'total_value' => array( 'description' => __( 'Value of the Cost of Goods Sold for the order item.', 'woocommerce' ), 'type' => 'number', 'readonly' => true, 'context' => array( 'view', 'edit' ), ), ), ); return $schema; }