'number', 'readonly' => true, 'context' => array( 'view', 'edit' ), 'description' => 'Average product rating.', ); return $properties; } add_filter( 'woocommerce_rest_report_products_schema', 'add_product_extended_attributes_schema' ); /** * Extended attributes can be used to obtain any attribute from a WC_Product instance that is * available by a `get_*` class method. In other words, we can add `average_rating` because * `get_average_rating` is an available method on a WC_Product instance. * * @param array $extended_attributes - Extra information from WC_Product instance. * @return array - Extended attributes. */ function add_product_extended_attributes( $extended_attributes ) { $extended_attributes[] = 'average_rating'; return $extended_attributes; } add_filter( 'woocommerce_rest_reports_products_extended_attributes', 'add_product_extended_attributes' );