如何修改网站代码以通过IP地址更改货币?
我尝试了太多基于IP地址更改货币的插件,但它无法正常工作。我需要一些自定义代码或插件来解决这个问题。
任何人都可以提供一些吗?
答案 0 :(得分:0)
这也是第三方api。我不确定这个的准确性,但试一试。
使用它我们得到当前货币。然后,您可以使用以下插件挂钩动态设置货币。
function set_currency_programmatically($selected_currency) {
// Use the usercountry api here to find the currency.
$selected_currency = 'USD';
return $selected_currency;
}
add_filter('wc_aelia_cs_selected_currency', 'set_currency_programmatically', 0);