WC_Tax::update_tax_rate_locations()private staticWC 2.3.0

Updates locations (postcode and city).

Internal use only.

Метод класса: WC_Tax{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WC_Tax::update_tax_rate_locations( $tax_rate_id, $values, $type );
$tax_rate_id(int) (обязательный)
Tax rate ID to update.
$values(массив) (обязательный)
Values to set.
$type(строка) (обязательный)
Location type.

Список изменений

С версии 2.3.0 Введена.

Код WC_Tax::update_tax_rate_locations() WC 8.7.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' );
}