currently I hide all product price for out of GB but I would like to show product price only if they have a TAG.
my code to hide product price out of GB is anyone can help me ? please ?
/** hiding prices if outside of gb*/
add_filter( 'woocommerce_get_price_html', 'country_geolocated_based_hide_price', 10, 2 );
function country_geolocated_based_hide_price( $price, $product ) {
// Get an instance of the WC_Geolocation object class
$geo_instance = new WC_Geolocation();
// Get geolocated user geo data.
$user_geodata = $geo_instance->geolocate_ip();
// Get current user GeoIP Country
$country = $user_geodata['country'];
return $country !== 'GB' ? '' : $price;
}
/** fin hiding prices if outside of gb*/
thank you
show product price for out of GB and show product price only if they have a TAG
2
Answers
Thank you Faisal ! you help me so much :)
first impression, I thought it working but prices are hided on GB as well is product haven't tag.
GB = can see everything outside of GB = can see prices only product has the tag
You can modify your code this way: