I would like to add an action in woocommerce to remove the tax from orders when created in the backend and for special users as customers.
This code is working for the normal order process on the website, but not on the backend
add_action( 'woocommerce_checkout_update_order_review', 'remove_tax_from_user' );
add_action( 'woocommerce_before_cart_contents', 'remove_tax_from_user' );
function remove_tax_from_user( $post_data ) {
global $woocommerce;
$username = $woocommerce->customer->get_username();
$user = get_user_by('login',$username);
if($user)
{
if( get_field('steuer_befreit', "user_{$user->ID}") ):
$woocommerce->customer->set_is_vat_exempt( true );
endif;
}
}