Posting the solution that worked for me in case it helps anyone in the future (Credit to Rup & WooCommerce Community Slack)
I was filtering the tax class getter on the cart side and that was doing what I needed, so I was focused on figuring out how to also filter the tax class getter on the order side. Devinsays on Community Slack recommended the obvious-in-hindsight solution of filtering also the setter on the cart side and then the order side just works without any filter. In other words, when I re-assign the tax class for the calculation on the cart side, actively set it on order creation. Then it will be attached to the order item for the recalculate later. Something like this:
function also_reassign_the_setter($item, $cart_item_key, $values, $order){
//some custom logic
$item->set_tax_class('class_one');
}
add_action('woocommerce_checkout_create_order_line_item', 'also_reassign_the_setter', 20, 4);
Related Posts:
- Woocommerce – Hide a Column in Cart Table
- Remove an action by extending class and replacing it
- Difference Between Filter and Action Hooks?
- Explanation of the “posts_join” and “posts_fields” filter hooks?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- How do I Make a Theme “plugin-ready”?
- How to modify post content before writing to database?
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Is it possible to create an action hook using do_action() within add_action()?
- Hook for post permalink update
- Dynamically Override Fancy Title
- Define a function outside a class and call the function using action or filter hook
- Synchronize Custom post type tags to WordPress default posts tags
- How do I change the initial quantity of a product in woocommerce?
- WordPress after content Hook & external template part
- Namespaced action and filter tags
- best practice for query string values – get_query_var always empty for my value supplied in query string
- get_current_screen() return null
- how to add custom functionality after woocommerce place order button
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- Can’t get woocommerce_get_price_html to work [closed]
- Add default user field to WooCommerce checkout [closed]
- WordPress custom taxonomy check box to dropdown
- How to get all queries’s results after they have executed?
- hook filter after the_content on a specific page
- Bind a function with its own argument to show something dynamically after every content
- Hook add_attachment error
- Call to undefined function is_home() or any conditional tags
- Associate multiple email addresses with the same user account, so they can log in with either
- Update variable value via add_filter
- Configure WordPress to Generate Scheme-less Relative URLs
- Hide one specific woocoomerce product
- How to find list of all functions bind to a particular hook from my plugin?
- apply_filters() and call_user_func() to define and call a function outside a class
- Limit get_next_post to posts from the same author
- Override woocommerce loop-start.php from theme using plugin?
- Any way, hook to add content right before the “read more” link?
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- WordPress Reset password Strength set to medium
- Add_action not calling callback function
- how to retrieve post_id under woocommerce_add_to_cart_validation hook?
- woocommerce single product page hook not working
- How do I replace title with my plugin?
- Woocommerce: block user removing cart item
- Apply function on all action hooks?
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Ninja Forms: Front-End Forms, Post ID?
- Custom fields in the billing address section woocommerce
- how to execute a function only when i send an order to trash [closed]
- Are woocommerce_thankyou hook and is_order_received_page() redundant? [closed]
- Insert, update or remove data from database (usermeta)
- Getting products information, in woocommerce based on products ID
- How to direct WordPress to load custom template for custom post type
- Is there any way to get post meta from publish_post hook?
- How can i add product Accessories from front-end using custom php form?
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- Add a custom submenu under submenu in a Custom WordPress Plugin
- PHPUnit Testing and woocommerce Constant
- using filter and hook inside class
- Redirect WooCommerce checkout to cart
- WC REST API Error Handling
- How do I ensure I can loop through every enqueued script and CSS?
- Hook for validating and rejecting frontend image upload
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Nested Hooks with do_action for performance reasons – safe/necessary?
- User meta query using Wildcard
- How do I remove an action hook inside a class that is called by another class?
- Pre-populated WooCommerce checkout fields: dropdown fields issue
- Woocommerce Product finder feature on home page
- want to confirm popup with “Yes” and “No” button when user click on add to cart
- Problem in plugin debuging in wordpress
- How to remove the WooCommerce Product->Category thumbnail from admin [closed]
- Woocommerce Single Product Tabs Got Duplicate
- Woocommerce product not appearing in category list page when created programatically [closed]
- woocommerce wc_get_product is not fetching all the product of particular category
- Override WooCommerce files from plugin
- OOP development and hooks
- woocommerce add a new bulk action in the bulk actions dropdown in the orders list
- How to trigger WooCommerce user profile edit change?
- Add suffix to price html does not work
- Plugin Development – Call to undefined function comment_exists()
- Override theme’s WooCommerce file
- With what hook do I remove WooCommerce existing Product Data Tab form fields?
- User avatar-ACF fields
- WC_Geolocation not found inside plugin
- Redirect theme directory to plugin theme directory
- remove different admin menu for specific users
- Change Front page displays settings conditionally when user is online
- How to use functions from Woocommerce documentation?
- login_message filter not working
- replacing jquery google cdn with a new version dynamically
- Prevent plugin activation and add admin notice
- external Integration with wordpress timeout error
- I have a plugin where in I have to change the title of the page dynamically by sending parameter to the_title filter
- WordPress Dropdown image select
- Modify search form with plugin
- Handle changed Woocommerce function
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- Making Woocommerce optimized for more than 500k products