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?
- How to create an API for my plugin?
- How Can I Add a Filter to Class Instance Only?
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- add_filter and remove_filter added before and after wp_query
- Call activation hook multiple times
- Two-step login process – Is it possible?
- How can I hook into existing WordPress Bulk actions?
- WordPress Media mime type filter problem 4.0
- Woocommerce add custom button to backend order table
- How do I hook a custom discount to change a WC_Order price total on WooCommerce?
- Earliest WP Hook to Safely and Reliably Redirect
- What is rich_editing?
- merging an array to an existing array using add_filter
- Hook into theme-switching later than `setup_theme`
- Is it possible to delay execution of shortcode output callback?
- Why my database table not created on activation?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- Act on user meta updated, but only once
- Is there any way to allow a plugin to write over a previous version?
- How to call function at the bottom of post using plugin?
- How do I add custom column to woocommerce cart?
- WooCommerce Conditional Tag inside plugin
- update woocommere total value on checkout based on selected payment method
- Problems with: manage_${post_type}_posts_columns
- How To Change Logout Screen Title
- Add code inside specific wordpress standard function
- Conditional hook based on the core function that is calling it
- PHP – Extend WordPress Woocommerce Revenue Analytics with custom field
- Filtering WooCommerce Orders by Category
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- How can I create a custom plugin that allows anonymous users to signup without registering?
- How to call code when adding WooCommerce menu items via woocommerce_account_menu_items
- Ajax +wordpress onClick link redirect to new page and create html content
- How to replace settings in WordPress plugin from a theme
- Adding filter to the title without affecting the menu title
- How to validate inputs with filter in register_setting callback
- Creating posts with links from a txt file
- Getting Post ID at “stylesheet” and “template” hooks
- WC REST API Error Handling
- User meta query using Wildcard
- How to remove the WooCommerce Product->Category thumbnail from admin [closed]
- woocommerce add a new bulk action in the bulk actions dropdown in the orders list
- Plugin Development – Call to undefined function comment_exists()
- Prevent plugin activation and add admin notice
- get_comment_meta() for a filter hook in a plugin
- Custom signature appears twice on page
- Declaring a new woo commerce product type i get this error
- Can I use a hook other than ‘init’ to handle form submissions?
- Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
- How to design WooCommerce-like admin tabs for plugin settings page?
- What is the meta_query key name for the woo product average rating? [closed]
- I want to redirect user to an amazon product page from my wordpress website when they add product to there cart [closed]