WordPress
0
Вклад в тег
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["remember_select"];
$get_user_currency = strtolower($user_city . '_price');
if ($get_user_currency != '') {
switch ($user_city) {
case 'gorod0':
$new_price = get_post_meta($post_id, 'gorod0', true);
break;
case 'gorod1':
$new_price = get_post_meta($post_id, 'gorod1', true);
break;
case 'gorod2':
$new_price = get_post_meta($post_id, 'gorod2', true);
break;
}
if ($new_price == '') {
$new_price = $price;
}
}
return $new_price;
}