WC_REST_Orders_Controller::add_cogs_related_schema
Add the Cost of Goods Sold related fields to the schema.
Метод класса: WC_REST_Orders_Controller{}
Хуков нет.
Возвращает
Массив. The updated schema.
Использование
// private - только в коде основоного (родительского) класса $result = $this->add_cogs_related_schema( $schema ): array;
- $schema(массив) (обязательный)
- The original schema.
Код WC_REST_Orders_Controller::add_cogs_related_schema() WC REST Orders Controller::add cogs related schema WC 10.4.2
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;
}