Skip to content

Commit 582da20

Browse files
Merge pull request #5 from SmartPackWMS/v0.0.2
V0.0.2
2 parents 1af607c + d8447ca commit 582da20

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Controllers/RestRoutes_Controller.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,21 @@ public function exportProducts(WP_REST_Request $request) {
221221

222222
$product_data[] = Helpers::getProductData($product->ID);
223223
}
224-
224+
225+
if (!isset($_GET['ignoreCount'])) {
226+
$products_count = wp_count_posts( $post_type = 'product' );
227+
$product_variation_count = wp_count_posts( $post_type = 'product_variation' );
228+
$product_found = ($products_count->publish + $product_variation_count->publish);
229+
} else {
230+
$product_found = null;
231+
}
232+
225233
return new WP_REST_Response([
226234
'content' => $product_data,
227235
'pagination' => [
228236
'limit' => $limit,
229237
'offset' => $offset,
230-
'found' => count($product_data)
238+
'found' => $product_found
231239
]
232240
]);
233241
}

0 commit comments

Comments
 (0)