I have been trying to disable VAT on products purchased by someone in the EU, if they have a valid VAT number.
I purchased a plugin from WooThemes, which is supposed to do what I am after above, but because I am not using the standard WooCommerce/PayPal checkout experience, and instead I am using a PayPal Express plugin that they offer, so the hooks/actions that the EU VAT Number plugin used are no longer being called I assume.
I was trying to reassign this plugins functions to different hooks, so that it would work as requested. I forced the plugin to appear on the cart.php WooCommerce template, rather than the default Shipping Details page, and then added the process_checkout
function [which just processes the VAT number entered and removes VAT if its valid] to the woocommerce_after_cart_item_quantity_update
hook from WooCommerce. From what I can tell, this action is run whenever ‘Update Cart’ is clicked BUT it doesn’t seem to run unless the quantity has changed AND also doesn’t seem to run unless the quantity is a new quantity that hasn’t already been calculated and cached.
I really just need to force woocommerce_after_cart_item_quantity_update
to run as soon as the button is pressed, (i think,).
If I am heading down the wrong path that would also be great to hear
I think you’ve got the right idea, but you just need to do it on a different hook.
Instead of woocommerce_after_cart_item_quantity, I’d try woocommerce_after_cart_totals and see if that works better for you.