How to disallow any currency for any country
Request from the customer: Basically, add a column to the existing table, with a dropdown that shows “all countries” by default OR “selected countries” comma delimited
this way, I can accept Euro only in Euro countries and USD in others.
This will affect the currency dropdown – in case that the current GEO supports one currency, the currency dropdown will not show in client side.
I think that this feature is a must – as it will bring even more flexibility to your plugin.
danny leon
To avoid overloading of the plugin interface by new elements such feature can be realized by hook woocs_currency_data_manipulation:
add_filter('woocs_currency_data_manipulation', function($currencies) { global $WOOCS; $user_country = $WOOCS->storage->get_val('woocs_user_country'); switch ($user_country) { case 'ES': unset($currencies['USD']); unset($currencies['GBP']); break; case 'AU': unset($currencies['EUR']); break; default: break; } return $currencies; }, 1, 1);
Use Alpha-2 code for countries: https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes