WooCommerce-为某些特定的用户角色变量产品启用“零费率”税种

我想将“零利率”应用到具有vip作用的客户。 因此,当我向上看时,发现以下代码。 但是问题在于它仅适用于简单的产品,而对可变产品完全不起作用。 我一直在用stackoverflow搜索Internet大约一三个小时,但是我找不到在两种情况下都能正常工作的代码,并且它们都是在2016年或2017年编码的,因此我认为它与当前版本的Woocommerce。

function zero_rate_for_custom_user_role( $tax_class,$product ) {
    // Getting the current user
    $current_user = wp_get_current_user();
    $current_user_data = get_userdata($current_user->ID);

    //  <== <== <== <== <== <== <== Here you put your user role slug
    if ( in_array( 'customer_family',$current_user_data->roles ) )
        $tax_class = 'Zero Rate';

    return $tax_class;
}
add_filter( 'woocommerce_product_tax_class','zero_rate_for_custom_user_role',1,2 );

感谢建议。

wyzxf101 回答:WooCommerce-为某些特定的用户角色变量产品启用“零费率”税种

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3081730.html

大家都在问