Change Tax Class programmatically when Recalculating an existing Order
-
Hello. I’m hoping someone can’t point me to what I am overlooking.
CIRCUMSTANCE:
We have some odd business logic whereby a custom usermeta field affects the appropriate tax class. We have three customer “types” (which is this user meta field) with three corresponding custom Tax Classes. When we calculate taxes on a Cart, we run a filter on woocommerce_product_get_tax_class and re-assign the Tax Class based on looking up this user meta. It works perfectly for our needs.PROBLEM:
We have frequent need to use the Recalculate button on the edit Order page in WP Admin. I cannot find where I can filter or hook the tax class assignment. It seems to be in the calculate_taxes() method in the class-wc-order-item.php class (line 220: https://github.com/woocommerce/woocommerce/blob/trunk/includes/class-wc-order-item.php#L220 )–and surely enough if insert line 221 there like $calculate_tax_for[‘tax_class’] = ‘somethg_specific’ it does exactly what I am looking to do.Is there a way I can do this without hacking core?
Thanks vastly for any help. I’m at a complete loss and against a clock.
- The topic ‘Change Tax Class programmatically when Recalculating an existing Order’ is closed to new replies.