Reputation: 13
I want to show different price for different countries. The pricing rule will be like (regular_price + 1)*conversion_rate
. Now I am using this snippet but it's not showing the price anywhere. I echo it but it only showing beside the cart button.
add_filter('woocommerce_get_price', 'adjust_price_for_gcc', 10, 2);
function adjust_price_for_gcc($price, $product) {
$location = WC_Geolocation::geolocate_ip();
$gcc_countries = ['BH', 'BD', 'OM', 'QA', 'SA', 'AE']; // GCC country codes
if (in_array($location['country'], $gcc_countries)) {
$price = $price + 1; // Increase price by 1 for GCC customers
}
echo $price;
return $price;
}
please help. I am new to wordpress development.
Upvotes: 0
Views: 25