I’m trying to hide the products price and add to cart button from woocommerce pages on specific countries.
i’ve found Turn Woocommerce shop into catalog for geolocated countries? but it works only for one country
I couldn’t find a solution to change this code to be able to target more than 1 country. I made an array with all the countries I needed
$countries = array("IT","DE","FR","AT","BE","BG","CY","HR","DK","EE","FI","EL","IE","LV","LT","LU","MT","NL","PL","PT","CZ","RO","SK","SI","ES","SE","HU");
If someone could help me it would be great
2
Answers
That functionality, as I’m sure you’ve noticed, isn’t part of the core features of the WooCommerce plugin.
Also, without knowing which plugins you’ve already considered, we might be covering the same ground twice. With that said, you’ll definitely want to look into using 3rd party plugins for that. Possible options include:
https://www.extendons.com/product/woocommerce-geolocation-based-products-plugin-geo-ip-filter/
https://codecanyon.net/item/woocommerce-geolocation-plugin-ip-based-products-filter/22022059
https://cyberchimps.com/how-to-redirect-based-on-geolocation-on-wordpress/
Note: You’ll want to contact each of the respective developers to make sure their products meet your project requirements.
You could use this snippet below, piggybacking off of the built-in geolocation of WooCommerce. You will need to make sure geolocation is enabled in your WooCommerce general settings.
Geolocation info here: https://woocommerce.github.io/code-reference/classes/WC-Geolocation.html