Implement network-wide WooCommerce Tax settings
WooCommerce Tax area provides the necessary tools to create the required taxation for on-sale products. Setting up Taxes in WooCommerce is straightforward, through WooCommerce > Settings > Tax interface:
Different tax classes and appropriate Rates, per specific Country, State, Zip, City etc area configurable:
On check-out, the current shop tax set-up applies to all products in the shopping cart. The check-out location is settable through the plugin options, or this can be free to choose by the customer. I such case, the Tax rates need to synchronize on all shops, to provide unitary prices and costs. Setting up and updating the taxes on the network is not be the best solution, this takes time and opens the possibility for human errors.
A Global Tax is possible for all shops in the network through a custom code. This ensures all data is loaded from the main shop. Also saved to the same site ( or any other in the network, if required ). The global tax is also suitable for all check-out types such as Single Check-out type and Each Store check-out.
The following code is required for a Global Tax setup. This goes within a custom file on /wp-content/mu-plugins/ directory:
<?php global $wpdb; define('WooGC_GlobalTax_woocommerce_tax_rates', $wpdb->base_prefix . 'woocommerce_tax_rates'); define('WooGC_GlobalTax_wc_tax_rate_classes', $wpdb->base_prefix . 'wc_tax_rate_classes'); add_filter('query', 'woo_gc_query'); function woo_gc_query( $query ) { global $wpdb; //check for term_exists() query OR run_seccond_pass if ( preg_match( "/wp(_\d+)?_woocommerce_tax_rates/i", $query ) || preg_match( "/wp(_\d+)?_wc_tax_rate_classes/i", $query ) ) { $replace_table = $wpdb->prefix . 'woocommerce_tax_rates'; $replacement_table = WooGC_GlobalTax_woocommerce_tax_rates; $query = str_replace( $replace_table, $replacement_table, $query); $replace_table = $wpdb->prefix . 'wc_tax_rate_classes'; $replacement_table = WooGC_GlobalTax_wc_tax_rate_classes; $query = str_replace( $replace_table, $replacement_table, $query); } return $query; }
Using the above code, all Tax Classes and individual Rates becomes available to all shops in the network. Add New and Updates are available from any site.