I would like to add "We ship to {country name}
" in woocommerce header based on user geoip country name?
I would like to Write an html content in the header of my woocommerce store, Such as We ship to "Your Country name".
Any help will be really appreciated?
I have woocommerce geolocation enabled already.
You can make a custom function based on
WC_Geolocation
Class this way:Code goes in function.php file of your active child theme (or active theme). Tested and works.
USAGE
You will add the following code in your child theme's
header.php
file:1) in between html code:
2) or in between php code:
Converting this to Shortcode:
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Normal shortcode usage (in the backend text editor):
or in php code: