WC_Tax::update_tax_rate_locations
Updates locations (postcode and city).
Internal use only.
Method of the class: WC_Tax{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Tax::update_tax_rate_locations( $tax_rate_id, $values, $type );
- $tax_rate_id(int) (required)
- Tax rate ID to update.
- $values(array) (required)
- Values to set.
- $type(string) (required)
- Location type.
Changelog
| Since 2.3.0 | Introduced. |
WC_Tax::update_tax_rate_locations() WC Tax::update tax rate locations code WC 10.3.6
private static function update_tax_rate_locations( $tax_rate_id, $values, $type ) {
global $wpdb;
$tax_rate_id = absint( $tax_rate_id );
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations WHERE tax_rate_id = %d AND location_type = %s;",
$tax_rate_id,
$type
)
);
if ( count( $values ) > 0 ) {
$sql = "( '" . implode( "', $tax_rate_id, '" . esc_sql( $type ) . "' ),( '", array_map( 'esc_sql', $values ) ) . "', $tax_rate_id, '" . esc_sql( $type ) . "' )";
$wpdb->query( "INSERT INTO {$wpdb->prefix}woocommerce_tax_rate_locations ( location_code, tax_rate_id, location_type ) VALUES $sql;" ); // @codingStandardsIgnoreLine.
}
WC_Cache_Helper::invalidate_cache_group( 'taxes' );
}