I'm have a woocommerce site that has multiple pickup options in different tax brackets along with shipping. The store is configured to calculate tax according to the customer shipping address. I'm trying to figure out how to create a hook that will update the "shop base address" values so the tax calculation is correct. I've determined the necessary hooks to update the shop base address: add_filter( 'woocommerce_default_address_fields' , __NAMESPACE__ . '\remove_woocommerce_postcode_validation', 999, 1); add_filter( 'woocommerce_countries_base_city' , __NAMESPACE__ . '\set_woocommerce_countries_base_city' ); add_filter( 'woocommerce_countries_base_state' , __NAMESPACE__ . '\set_woocommerce_countries_base_state' ); add_filter( 'woocommerce_countries_base_postcode' , __NAMESPACE__ . '\set_woocommerce_countries_base_postcode' ); I originally had this running in the woocommerce_package_rates with some other changes - but that doesn't know what shipping / pickup option is currently selected. Any suggestions on what hook would be best to be able to run through an if loop to match a pickup location and then update the shop base address accordingly while also make sure the tax calc happens? Thanks in advance!
Jese Leos
September 13, 2024
Verified user
For this I suggest you to use the woocommerce_checkout_update_order_review hook which dynamically update the WooCommerce shop base address based on the selected shipping method (including different pickup locations). woocommerce_checkout_update_order_review is triggered after the shipping method has been selected but before the tax calculation.