woocommerce/api/tools/delete-all-products.php

17 lines
324 B
PHP
Raw Normal View History

2021-05-19 05:43:07 +00:00
<?php
register_woocommerce_admin_test_helper_rest_route(
'/tools/delete-all-products/v1',
'tools_delete_all_products'
);
function tools_delete_all_products() {
$query = new \WC_Product_Query();
$products = $query->get_products();
foreach ( $products as $product ) {
$product->delete( true );
}
return true;
}