我已经 Build 了一个拥有多个用户(B2C和B2B)的woocommerce商店 . 其中一些将自动免税,只是从购物车/结账中消失税 . 我使用动态定价插件为不同的角色提供不同的价格,但税收变化没有选项 .
我找到了这个答案,并试图把它放到位Role based taxes in woocommerce但是正如@ Jplus2所说,@ dryan144解决方案并不好,因为它只在结账时应用而不是在购物车上 . 我试图找出方法,但我仍然需要刷新my 'cart' page以显示税收为0(因为它们包含在"guest"或"customer"的价格中,当我的购物车页面被调用时启动操作的任何帮助?
我做了以下事情:
add_filter( 'woocommerce_before_cart_contents', 'prevent_wholesaler_taxes' );
add_filter( 'woocommerce_before_shipping_calculator', 'prevent_wholesaler_taxes' );
add_filter( 'woocommerce_before_checkout_billing_form', 'prevent_wholesaler_taxes' );
function prevent_wholesaler_taxes() {
global $woocommerce;
if ( is_user_logged_in() && !(current_user_can('customer'))){
$woocommerce->customer->set_is_vat_exempt(false);
} else {
$woocommerce->customer->set_is_vat_exempt(true);
}
} //end prevent_wholesaler_taxes
只有在刷完我的购物车之后工作才能完成's working straight away sometimes but most of the time it' s . 尝试将https://eshoes.com.au/product/test-shoes08/添加到购物车然后 - >查看您的购物篮
任何帮助都会受到高度赞赏;)
干杯
1 回答
这个解决方案完美无缺,而不是使用set_is_vat_exempt()我只使用$ tax)class = 'Zero Rate':