Title: Setting Shipping Tax programatically
Last modified: June 15, 2022

---

# Setting Shipping Tax programatically

 *  Resolved [ktoldy](https://wordpress.org/support/users/ktoldy/)
 * (@ktoldy)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/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)

 *  [Mirko P.](https://wordpress.org/support/users/rainfallnixfig/)
 * (@rainfallnixfig)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/setting-shipping-tax-programatically/#post-15741545)
 * Hi there,
 * This is a fairly complex development topic. I’m going to leave it open for a 
   bit to see if anyone is able to chime in to help you out.
 * I can also recommend the WooCommerce [Developer Resources Portal](https://developer.woocommerce.com/)
   for resources on developing for WooCommerce.
 * You can also visit the [WooCommerce Facebook Community](https://www.facebook.com/groups/advanced.woocommerce/)
   group or the `#developers` channel of the [WooCommerce Community Slack](https://woocommerce.com/community-slack/).
   We’re lucky to have a great community of open-source developers for WooCommerce,
   and many of our developers hang out there, as well.
 * Cheers.
 *  Thread Starter [ktoldy](https://wordpress.org/support/users/ktoldy/)
 * (@ktoldy)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/setting-shipping-tax-programatically/#post-15742323)
 * Hi,
 * Thanks a lot for the reply, yeah we’ve scanned through the available functions
   and the object model but were not able to find a quick solution so we thought
   to post here.
 *  Plugin Support [Tamirat B. (a11n)](https://wordpress.org/support/users/tamirat22/)
 * (@tamirat22)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/setting-shipping-tax-programatically/#post-15742568)
 * Hello [@ktoldy](https://wordpress.org/support/users/ktoldy/)!
 * Thanks for the reply
 * > we’ve scanned through the available functions and the object model but were
   > not able to find a quick solution so we thought to post here.
 * If you need continued guidance with customizations, you can reach out to a developer
   or one of our experts on the WooCommerce.com customization page – [https://woocommerce.com/customizations/](https://woocommerce.com/customizations/).
 * Hope this helps!
 *  [Igor H](https://wordpress.org/support/users/ihereira/)
 * (@ihereira)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/setting-shipping-tax-programatically/#post-15763809)
 * We haven’t heard back from you in a while, (I think that at this point you have
   been able to find a solution) so I’m going to mark this as resolved – we’ll be
   here if and/or when you are ready to continue.
 * Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Setting Shipping Tax programatically’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 4 replies
 * 4 participants
 * Last reply from: [Igor H](https://wordpress.org/support/users/ihereira/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/setting-shipping-tax-programatically/#post-15763809)
 * Status: resolved