【发布时间】:2017-10-18 05:58:36
【问题描述】:
我已通过以下代码在商店页面和购物车页面中为批发客户申请“零税率”税级-
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);
if ( in_array( 'wholesale_customer', $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 );
它适用于简单产品,但对于可变产品最低和最高价格仍显示含税价格。
请给我解决方案,我怎样才能排除税或对可变产品应用“零税率”。
作为参考,我已尝试此解决方案但没有奏效。
function woocommerce_variation_prices_hash($price_hash, $product, $display) {
if ( $display )
$price_hash[] = $product->get_tax_class();
return $price_hash;
}
add_filter( 'woocommerce_get_variation_prices_hash', 'woocommerce_variation_prices_hash', 10, 3 );
【问题讨论】:
标签: woocommerce