Skip to content

Commit

Permalink
Delete tax rates by country fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisnissle committed Dec 22, 2023
1 parent 556d5dc commit 39fd196
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -906,16 +906,15 @@ public static function tax_rate_is_northern_ireland( $rate ) {
}

public static function delete_tax_rates_by_country( $country ) {
global $wpdb;

$country = strtoupper( $country );

foreach ( self::get_tax_class_slugs() as $tax_class ) {
$tax_rates = \WC_Tax::find_rates(
array(
'tax_class' => $tax_class,
'country' => $country,
)
);
$tax_rates = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$wpdb->prefix}woocommerce_tax_rates` WHERE `tax_rate_class` = %s AND `tax_rate_country` = %s;", $tax_class, $country ) );

foreach ( $tax_rates as $tax_rate_id => $tax_rate ) {
\WC_Tax::_delete_tax_rate( $tax_rate_id );
foreach ( $tax_rates as $tax_rate ) {
\WC_Tax::_delete_tax_rate( $tax_rate->tax_rate_id );
}
}
}
Expand Down

0 comments on commit 39fd196

Please sign in to comment.