donglun4682
2018-05-29 03:21
浏览 75
已采纳

如何在wordpress中修复对未定义函数get_woocommerce_currency()的调用?

I'm developing a custom shipping plugin to my WooCommerce website.

I want to change shipping method to my custom method if and only if the user's currency is USD. Apart from USD, I'm using LKR as my other currency unit. If the currency is in LKR different shipping method should be applied.

So I tried to check whether the user's current base currency is in USD by using this code in my plugin.php file,

My plugin.php code includes in -> wp-content/plugins/my-plugin

 if ( 'USD' !== get_woocommerce_currency() ) {
    echo 'Hello  ';
    //my action
}   

So now every time I run this code I'm getting a fatal error saying

Call to undefined function get_woocommerce_currency()

Then I tried including the option.php ,

include_once('wp-includes/option.php');

still getting the same error message.

How to fix it and why I'm getting that error?

What I want to do is just to check user's current currency and activate the plugin if the currency is only in USD.

Thanks.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题