Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Last active February 25, 2020 04:22
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ChromeOrange/8287925 to your computer and use it in GitHub Desktop.
Save ChromeOrange/8287925 to your computer and use it in GitHub Desktop.
Delete all tax rates from WooCommerce
/**
* Delete ALL WooCommerce tax rates
*
* Add to your theme functions.php then go to woocommerce -> system status -> tools and there will be a delete all tax rates button http://cld.wthms.co/tXvp
*/
add_filter( 'woocommerce_debug_tools', 'custom_woocommerce_debug_tools' );
function custom_woocommerce_debug_tools( $tools ) {
$tools['woocommerce_delete_tax_rates'] = array(
'name' => __( 'Delete Tax Rates',''),
'button' => __( 'Delete ALL tax rates from WooCommerce','' ),
'desc' => __( 'This tool will delete all your tax rates allowing you to start fresh.', '' ),
'callback' => 'woocommerce_delete_tax_rates'
);
return $tools;
}
/**
* Delete Tax rates
*/
function woocommerce_delete_tax_rates() {
global $wpdb;
$wpdb->query( "TRUNCATE " . $wpdb->prefix . "woocommerce_tax_rates" );
$wpdb->query( "TRUNCATE " . $wpdb->prefix . "woocommerce_tax_rate_locations" );
echo '<div class="updated"><p>' . __( 'Tax rates successfully deleted', 'woocommerce' ) . '</p></div>';
}
@DevWael
Copy link

DevWael commented Dec 26, 2019

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment