相关疑难解决方法(0)

在woocommerce中基于角色的税收

我正在尝试建立一个woocommerce商店,以便具有批发商或设计师角色的用户将自动免税,只需从购物车/结账中消税.我使用动态定价插件为不同的角色提供不同的价格,但税收变化没有选项.

有人发布了这段代码:

// Place the following code in your theme's functions.php file and replace tax_exempt_role with the name of the role to apply to
add_action( 'init', 'woocommerce_customer_tax_exempt' );
function woocommerce_customer_tax_exempt() {
    global $woocommerce;
    if ( is_user_logged_in() ) {
        $tax_exempt = current_user_can( 'tax_exempt_role');
        $woocommerce->customer->set_is_vat_exempt( $tax_exempt );
    }
}
Run Code Online (Sandbox Code Playgroud)

这似乎是在前端工作但打破了后端.将它添加到functions.php后,当我回到管理区域并看到这个:http://i.imgur.com/nNHMSAZ.png(这只是新的Chrome错误页面吗?)

我无法弄清楚的另一件事是如何添加2个角色而不只是一个角色.

谢谢

php wordpress woocommerce

5
推荐指数
1
解决办法
4111
查看次数

标签 统计

php ×1

woocommerce ×1

wordpress ×1