Load all product types even when empty
This commit is contained in:
parent
5f723fc0d9
commit
14a1217218
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue