Используя код, подобный связанному ответу, вы можете попробовать следующее, которое будет нацелено на австралийских клиентов, чьи промежуточные итоги корзины составляют $1000
:
add_action( 'woocommerce_before_calculate_totals', 'apply_conditionally_zero_tax_rate', 10, 1 );
function apply_conditionally_zero_tax_rate( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
return;
// Targeting australia billing country only
if ( WC()->customer->get_billing_country() !== 'AU' )
return;
$defined_amount = 1000;
$subtotal = 0;
// Loop through cart items (1st loop - get cart subtotal)
foreach ( $cart->get_cart() as $cart_item ) {
$subtotal += $cart_item['line_total'];
}
// Targeting cart subtotal up to the "defined amount"
if ( $subtotal < $defined_amount )
return;
// Loop through cart items (2nd loop - Change tax rate)
foreach ( $cart->get_cart() as $cart_item ) {
$cart_item['data']->set_tax_class( 'zero-rate' );
}
}
Код находится в файле function.php вашей активной дочерней темы (или активной темы). Проверено и работает.