Add Tax Exempt form on checkout in woocommerce

前端 未结 5 2169
孤独总比滥情好
孤独总比滥情好 2021-01-03 03:14

I am trying to add a form to my checkout page so when a user clicks the \'Tax Exempt\' checkbox, a textbox will popup and ask the user what the Tax Exempt Id number is.

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 04:13

    Because $cart->remove_taxes(); is deprecated. This is what I used instead.

    I didn't have a form on the frontend, but have a user roll that is tax exempt. This was my solution.

    Also worth noting that set_is_vat_exempt(true) also works in the US to set as tax exempt.

    /**
     * Set customer as tax exempt if user is a wholesale customer
     */
    function remove_tax_for_exempt( $cart ) {
        global $woocommerce;
    
        if ( is_user_logged_in() && current_user_can( 'wholesale_customer' ) ) {
            $woocommerce->customer->set_is_vat_exempt(true);
        }
        return $cart;
    } 
    add_action( 'woocommerce_calculate_totals', 'remove_tax_for_exempt' );
    

提交回复
热议问题