I'm new to wordpress and writing plugins. I'm very close to finishing my plugin but I'm stuck on one last step. I have two functions. One for setting tax exempt and the other for recalculating the total. I need the second function to remove taxes if the first function sets the user as tax exempt. Any ideas on how I can get this working?
/* update the order total set exempt */
add_action( 'woocommerce_checkout_update_order_review', 'taxexempt_checkout_update_order_review' );
function taxexempt_checkout_update_order_review() {
global $woocommerce;
$woocommerce->customer->set_is_vat_exempt(FALSE);
if (!empty($_POST['tax_exempt_number'])) { $woocommerce->customer->set_is_vat_exempt(true); }
}
add_action( 'woocommerce_calculate_totals', 'remove_tax_for_exempt' );
function remove_tax_for_exempt( $cart ) {
global $woocommerce;
if ($woocommerce->customer->is_vat_exempt()){
$cart->remove_taxes();
$woocommerce->add_error(__('removing taxes'));
}
return $cart;
}