Merge pull request #5507 from lukecarbis/issue-5505
Add action hooks when saving tax rates
This commit is contained in:
commit
bbd7b16c17
|
@ -555,9 +555,7 @@ class WC_Settings_Tax extends WC_Settings_Page {
|
||||||
if ( $state == '*' )
|
if ( $state == '*' )
|
||||||
$state = '';
|
$state = '';
|
||||||
|
|
||||||
$wpdb->insert(
|
$tax_rate = array(
|
||||||
$wpdb->prefix . "woocommerce_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
'tax_rate_country' => $country,
|
||||||
'tax_rate_state' => $state,
|
'tax_rate_state' => $state,
|
||||||
'tax_rate' => $rate,
|
'tax_rate' => $rate,
|
||||||
|
@ -567,9 +565,12 @@ class WC_Settings_Tax extends WC_Settings_Page {
|
||||||
'tax_rate_shipping' => $shipping,
|
'tax_rate_shipping' => $shipping,
|
||||||
'tax_rate_order' => $i,
|
'tax_rate_order' => $i,
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
'tax_rate_class' => sanitize_title( $current_class )
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
do_action( 'woocommerce_tax_rate_added', $tax_rate );
|
||||||
|
|
||||||
|
$wpdb->insert( $wpdb->prefix . "woocommerce_tax_rates", $tax_rate );
|
||||||
|
|
||||||
$tax_rate_id = $wpdb->insert_id;
|
$tax_rate_id = $wpdb->insert_id;
|
||||||
|
|
||||||
if ( ! empty( $postcode ) ) {
|
if ( ! empty( $postcode ) ) {
|
||||||
|
@ -625,8 +626,11 @@ class WC_Settings_Tax extends WC_Settings_Page {
|
||||||
$tax_rate_id = absint( $key );
|
$tax_rate_id = absint( $key );
|
||||||
|
|
||||||
if ( $_POST['remove_tax_rate'][ $key ] == 1 ) {
|
if ( $_POST['remove_tax_rate'][ $key ] == 1 ) {
|
||||||
|
do_action( 'woocommerce_tax_rate_deleted', $tax_rate_id );
|
||||||
|
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
||||||
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d;", $tax_rate_id ) );
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,9 +652,7 @@ class WC_Settings_Tax extends WC_Settings_Page {
|
||||||
if ( $state == '*' )
|
if ( $state == '*' )
|
||||||
$state = '';
|
$state = '';
|
||||||
|
|
||||||
$wpdb->update(
|
$tax_rate = array(
|
||||||
$wpdb->prefix . "woocommerce_tax_rates",
|
|
||||||
array(
|
|
||||||
'tax_rate_country' => $country,
|
'tax_rate_country' => $country,
|
||||||
'tax_rate_state' => $state,
|
'tax_rate_state' => $state,
|
||||||
'tax_rate' => $rate,
|
'tax_rate' => $rate,
|
||||||
|
@ -660,7 +662,13 @@ class WC_Settings_Tax extends WC_Settings_Page {
|
||||||
'tax_rate_shipping' => $shipping,
|
'tax_rate_shipping' => $shipping,
|
||||||
'tax_rate_order' => $i,
|
'tax_rate_order' => $i,
|
||||||
'tax_rate_class' => sanitize_title( $current_class )
|
'tax_rate_class' => sanitize_title( $current_class )
|
||||||
),
|
);
|
||||||
|
|
||||||
|
do_action( 'woocommerce_tax_rate_updated', $tax_rate );
|
||||||
|
|
||||||
|
$wpdb->update(
|
||||||
|
$wpdb->prefix . "woocommerce_tax_rates",
|
||||||
|
$tax_rate,
|
||||||
array(
|
array(
|
||||||
'tax_rate_id' => $tax_rate_id
|
'tax_rate_id' => $tax_rate_id
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue