WordPress Plugin Delete WooCommerce Tax Rates

Feb 14, 2018

WordPress Plugin Delete WooCommerce Tax Rates


This post was originally created on our sister site WP Cover.
View Original Article
February 14, 2018


Over at Bold City Agency, one of our specialties is e-commerce development.  We work heavily with APIs to sync data from point of sale systems to WooCoomerce.  Often times, customers have complex tax calculations that must be calculated based on the zip code the shipment is going to.  When this is required, we will ask them for an Excel spreadsheet containing all the tax rates.  More often than not, the client needs to change the info (as there is always a small tweak) which presents a problem; WooCommerce has no way of clearing the tax rate table except through PHPMyAdmin or a similar tool.

ChromeOrange wrote a great custom function that truncates the database table for the tax rates.  All I did was wrap it into a quick plugin and save it for future use.  So I thought I would share.

Download The Plugin

Once you download, install, and activate the plugin, go to: WooCommerce -> System Status -> Tools. There will be a delete all tax rates button.


If you would prefer to add the custom function to your themes functions.php file, you can use the alternative:

 

/**
 * 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 '

' . __( 'Tax rates successfully deleted', 'woocommerce' ) . '

'; }

The post WordPress Plugin Delete WooCommerce Tax Rates appeared first on WP Cover.

Additional News

Perfect!

Let's get started. Fill out the form below to email us or request a call back.