0

When I try with this code in functions.php file WC_Geolocation::geolocate_ip() for getting current user country It's working fine.

But when I want to do it the same thing from a plugin, It throwing an error Fatal error: Class 'WC_Geolocation' not found

I have googled it and tried to find any possible solutions but didn't get it, please help me out.

Thanks in advance.

1 Answer 1

0

I suppose that the problem is because your plugin loads before Woocommerce plugin.

You should use it after Woocommerce is loaded, you have a hook to know that: woocommerce_init

Here you have a example to make a plugin of woocommerce: https://www.skyverge.com/blog/creating-custom-plugin-for-your-woocommerce-shop/

I hope it helps Regards.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.