Replies: 0
Hi there, hoping a WC guru is around to help with this 🙂
I’ve been using the following code to change the tax class of products when an admin is logged in;
function set_tax_rate( $tax_class, $product ) {
if ( is_user_logged_in() && (current_user_can( 'administrator' ) ) ) {
$tax_class = 'Admin Tax'; // 20% Tax
}
return $tax_class;
}
add_filter( 'woocommerce_product_get_tax_class', 'set_tax_rate', 1, 2 );
add_filter( 'woocommerce_product_variation_get_tax_class', 'set_tax_rate', 1, 2 );
This has been working really well until I upgraded WooCommerce not too long ago, my subtotal is now showing 0.01 more than I think it should be after the above code has changed the tax class.
For example in Woocommerce Basket/Checkout it now shows;
Non admins (At default 5% tax rate);
My Example Product x1 Price: £5.71
Subtotal: £5.71 <- Correct
Logged in admins (Using ‘Admin Tax’ rate);
My Example Product x1 Price: £5.71
Subtotal: £5.72 <– Wrong? – Should be £5.71?
In WooCommerce settings I am showing prices excluding tax.
‘Prices entered with tax’ is set to yes, and my default tax class is 5%. For My Example Product I have entered £6.00 as the price. Shipping is free.
So in my mind it should get the price excluding default 5% tax, which according to my understanding of WooCommerce it should be doing something like;
6/1.05 = 5.714285714285714 (Product price / Default Tax Rate)
Then when rounded should be 5.71.
So can anyone explain why the subtotal is 5.72 in this scenario?
I have no other WooCommerce plugins installed, am using Twenty Nineteen theme and am on the latest WordPress and WooCommerce versions (3.5.8 currently).
Any help on this would be hugely appreciated!
Many thanks
- This topic was modified 21 minutes ago by trogdoor9432.
- This topic was modified 17 minutes ago by trogdoor9432.