php - 如何根据 wordpress 中 woocommerce 中的 IP 地址更改产品的货币?
问题描述
我应该如何修改网站的代码以通过IP地址更改货币?
我尝试了太多插件来根据 IP 地址更改货币,但它无法正常工作。我需要一些自定义代码或插件来解决这个问题。
谁能提供一些?
解决方案
这也是第三方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);