// добавить поля цен
function price_moscow() {
the_field('price_moscow');
}
function price_tula() {
the_field('price_tula');
}
<select class="select_city" onchange="location.reload()">
<option value="">Выберите город</option>
<option value="moscow">Москва</option>
<option value="tula">Тула</option>
</select>
// вернуть нужную цену
add_filter('woocommerce_get_regular_price', 'return_custom_price', $product, 2);
add_filter('woocommerce_get_sale_price', 'return_custom_price', $product, 2);
add_filter('woocommerce_order_amount_item_subtotal', 'return_custom_price', $product, 2);
add_filter('woocommerce_get_price', 'return_custom_price', $product, 2);
function return_custom_price($price, $product)
{
global $post, $woocommerce;
$post_id = $product->id;
$user_city = $_COOKIE['city'];
$get_user_currency = strtolower($user_city . '_price');
if ($get_user_currency != '') {
switch ($user_city) {
case 'moscow':
$new_price = get_post_meta($post_id, 'price_moscow', true);
break;
case 'tula':
$new_price = get_post_meta($post_id, 'price_tula', true);
break;
}
if ($new_price == '') {
$new_price = $price;
}
}
return $new_price;
}