Setting Shipping Tax programatically
-
Hi,
We’re trying to change the Tax class of an order based on if a field is filled on the checkout page. We have successfully made this happen for the products to set the tax class to “reduced-rate” but we’re struggling to also change the shipping tax class based. Any hints?
Here’s the code for reference:
add_action( 'woocommerce_before_calculate_totals', 'change_tax_class_based_on_custom_input' ); function change_tax_class_based_on_custom_input( $cart ) { $billing_ic = (float) WC()->session->get('billing_ic'); if ( $billing_ic ) { foreach( $cart->get_cart() as $cart_item ){ $cart_item['data']->set_tax_class("reduced-rate"); } } }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Setting Shipping Tax programatically’ is closed to new replies.