You need to use the woocommerce_get_price
filter:
add_filter('woocommerce_get_price', 'return_custom_price', $product, 2);
function return_custom_price($price, $product) {
global $post, $woocommerce;
// Array containing country codes
$county = array('CH');
// Amount to increase by
$amount = 5;
// If the custromers shipping country is in the array
if ( in_array( $woocommerce->customer->get_shipping_country(), $county ) ){
// Return the price plus the $amount
return $new_price = $price + $amount;
} else {
// Otherwise just return the normal price
return $price;
}
}
EDIT:
To do this for just one product you can simply run a check on the product id via $post
:
add_filter('woocommerce_get_price', 'return_custom_price', $product, 2);
function return_custom_price($price, $product) {
global $post, $woocommerce;
// Array containing country codes
$county = array('CH');
// Get the post id
$post_id = $post->ID;
// Amount to increase by
$amount = 5;
// If the customers shipping country is in the array and the post id matches
if ( in_array( $woocommerce->customer->get_shipping_country(), $county ) && ( $post_id == '12' || $post_id == '5' || $post_id == '6' ) ){
// Return the price plus the $amount
return $new_price = $price + $amount;
} else {
// Otherwise just return the normal price
return $price;
}
}
Simply replace the ’12’ with your desired product ID. (‘5’ and ‘6’ are the checkout pages respectively)