I have a simple problem.
I have set up multiple tax rates for different countries. However, on the basket page - when not having visited the checkout page so far - it shows the tax from the base country.
In my case: I have a shop based in AT. I have set up taxes for AT and CH. If a user visits with a Switzerland IP, I restrict the country list to just Switzerland, and set a PHP variable. Nevertheless the country isn't in the woocommerce_countries anymore, WC calculates the taxes with the base country tax setting.
See those images:
taxes in basket - taxes on checkout
I want to show the correct tax BEFORE the checkout. I already figured out that the correct taxes are shown when the user has chosen a country on the checkout page, and a "$woocommerce->customer" node is available. But I struggle to make that happen.
Anyone got an idea how to do this? Here's my plugin code which does not work:
define('USERCOUNTRY', get_country_proper()); // returns 'CH'
$customer = new WC_Customer();
WC()->customer->set_country(USERCOUNTRY);
Result:
Fatal error: Call to a member function get() on a non-object in wp-content/plugins/woocommerce/includes/class-wc-customer.php on line 27
Update: The tax which will be used on the CART page (before entering a country on the CHECKOUT) is used here:
Woocommerce -> Settings -> Tax -> Default Customer Address: [Shop Base country | none] http://docs.woothemes.com/document/setting-up-taxes-in-woocommerce/
OK, can I alter this via script?
Thanks for any help.