WordPress at Your Fingertips
function is not described

WC_Tax::update_tax_rate_locations() private WC 2.3.0

Updates locations (postcode and city).

Internal use only.

{} It's a method of the class: WC_Tax{}

No Hooks.

Return

null. Nothing.

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.

Code of WC_Tax::update_tax_rate_locations() WC 5.9.0

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' );
}