• Resolved ktoldy

    (@ktoldy)


    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.

    (@rainfallnixfig)

    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 for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook Community group or the #developers channel of the WooCommerce 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

    (@ktoldy)

    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)

    (@tamirat22)

    Hello @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/.

    Hope this helps!

    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.