Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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>';
}
@isarmstrong

This comment has been minimized.

Copy link

commented Mar 31, 2015

This just made my day. Thank you @ChromeOrange

@worldsdream

This comment has been minimized.

Copy link

commented May 14, 2015

Very nice. Works great. Thanks!

@shannoncox

This comment has been minimized.

Copy link

commented Aug 3, 2015

Yes sir! Threw a couple of errors at the top due to the theme, but still worked like a charm. Thanks CO!

@tarfoot

This comment has been minimized.

Copy link

commented May 19, 2016

This looks like it's included in WooCommerce now. At least in our version 2.5.5 it looks like there's already a button in the System Status -> Tools.

@buyuran

This comment has been minimized.

Copy link

commented Feb 3, 2017

Viyola, works perfect. Way to go. Thanks a lot.

@KingGeneral

This comment has been minimized.

Copy link

commented Jul 23, 2017

Thanks for saving my day,

although i already using no tax, wc still buggy, thanks to this code now its fixed. PERFECT.

@Tursko

This comment has been minimized.

Copy link

commented Aug 8, 2017

Thank you. This saved the day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.