I have some difficulties to get something simple like the order object in my code. This is how it SHOULD work.
But for some reason, I don't get the order object, (it is NULL) out of this filter, so I think I have to get it myself. But here, I am stuck :(
I am testing it by clicking on "Recalculate sums" in the order - it should then remove or add the taxes to the order. It works when I just return true in my filter but I need some more logic.
add_filter("woocommerce_order_is_vat_exempt", 'tax_exempted_user');
function tax_exempted_user(){
global $order; // returns NULL
$user = $order->get_user();
if( $user->get_id() && get_field( 'field_60dd7434e8426', 'user_' . $user->get_id() ) == true ) {
return true;
} else {
return false;
}
}