Load all product types even when empty

This commit is contained in:
Claudio Sanches 2018-09-08 22:45:51 -03:00
parent 5f723fc0d9
commit 14a1217218
2 changed files with 14 additions and 2 deletions

View File

@ -40,9 +40,15 @@ class WC_REST_Report_Products_Totals_Controller extends WC_REST_Reports_Controll
*/
protected function get_reports() {
$types = wc_get_product_types();
$terms = get_terms(
array(
'taxonomy' => 'product_type',
'hide_empty' => false,
)
);
$data = array();
foreach ( get_terms( 'product_type' ) as $product_type ) {
foreach ( $terms as $product_type ) {
if ( ! isset( $types[ $product_type->name ] ) ) {
continue;
}

View File

@ -41,9 +41,15 @@ class WC_Tests_API_Reports_Products_Totals extends WC_REST_Unit_Test_Case {
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/reports/products/totals' ) );
$report = $response->get_data();
$types = wc_get_product_types();
$terms = get_terms(
array(
'taxonomy' => 'product_type',
'hide_empty' => false,
)
);
$data = array();
foreach ( get_terms( 'product_type' ) as $product_type ) {
foreach ( $terms as $product_type ) {
if ( ! isset( $types[ $product_type->name ] ) ) {
continue;
}