2021-05-19 05:43:07 +00:00
|
|
|
<?php
|
2023-08-09 00:20:34 +00:00
|
|
|
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
|
2021-05-19 05:43:07 +00:00
|
|
|
register_woocommerce_admin_test_helper_rest_route(
|
|
|
|
'/tools/delete-all-products/v1',
|
|
|
|
'tools_delete_all_products'
|
|
|
|
);
|
|
|
|
|
2023-08-09 00:20:34 +00:00
|
|
|
/**
|
|
|
|
* A tool to delete all products.
|
|
|
|
*/
|
2021-05-19 05:43:07 +00:00
|
|
|
function tools_delete_all_products() {
|
|
|
|
$query = new \WC_Product_Query();
|
|
|
|
$products = $query->get_products();
|
|
|
|
|
|
|
|
foreach ( $products as $product ) {
|
|
|
|
$product->delete( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|