At: www.TattiniBoots.com/Shop you see that there is a red store notice at the top.
Is there a way to hide this if the current viewer has a United States IP address?
At: www.TattiniBoots.com/Shop you see that there is a red store notice at the top.
Is there a way to hide this if the current viewer has a United States IP address?
2
Answers
In the Woocommerce admin, go to
Settings > General
. There will be an option under “General options” for “Default customer location”. Set this value to “Geolocate”.In your theme or plugin, you can use the function
wc_get_customer_default_location()
, which returns an array of containing country and state. Simply check the value of country in the array to see if it matches ‘US’ and modify your code as needed.Add the follows code snippet to do so –
Codes goes to your active theme’s functions.php