get_product_data($object_data, $context, $request); if ($object_data->is_type('grouped') && $object_data->has_child()) { $data['grouped_products'] = $object_data->get_children(); } $data = $this->add_additional_fields_to_object($data, $request); $data = $this->filter_response_by_context($data, $context); return $data; } /** * Remove fields that are not needed for external sync. * * @param WP_REST_Request $request Request object. * @return string[] */ public function get_fields_for_response($request) { $fields = parent::get_fields_for_response($request); return array_diff($fields, [ 'on_sale', 'permalink_template', 'generated_slug', 'price_html', 'related_ids', 'meta_data', 'date_created_gmt', 'date_modified_gmt', 'date_on_sale_from_gmt', 'date_on_sale_to_gmt', 'download_limit', 'download_expiry', 'tax_status', 'tax_class', 'tax_class', 'downloadable', 'downloads', 'download_limit', 'download_expiry', 'download_type', 'download_url', 'download_id', 'download_name', 'download_date', ]); } /** * Strip brand taxonomy terms from the response. * * @param WC_Product $product Product object. * @param string $taxonomy Taxonomy name. * @return string[] */ protected function get_taxonomy_terms($product, $taxonomy = 'cat') { if ($taxonomy === 'brand') { return ['']; } return parent::get_taxonomy_terms($product, $taxonomy); } }