Support » Plugin: WooCommerce » Changing tax with a radio button

  • Resolved Kieran McClung


    I’m currently trying to add something to my checkout which allows people to select whether they’re using the products domestically or commercially. Once this radio button is checked it should change the tax rate (domestic 5%, commercial 20%). 20% is the default at the moment.


    function kierans_vat_check($vatType) {
       <form method="post" id="vatChange" action="accept">
             <input name="vatCheck" type="radio" value="commercial" onclick="this.form.submit();" /> Commercial VAT
             <input name="vatCheck" type="radio" value="domestic" onclick="this.form.submit();" /> Domestic VAT
       $vatType = $_POST['vatCheck'];
       return $vatType;
    // Woocommerce select domestic (reduced rate) tax (commercial is default)
    add_filter('woocommerce_product_tax_class', 'big_apple_get_tax_class', 1, 2);
    function big_apple_get_tax_class($tax_class, $product, $vatType) {
       global $woocommerce;
       global $vatType;
       if($vatType == 'Domestic'):
          $tax_class = 'Reduced Rate';
       return $tax_class;

    What I’m trying to do here is run the big_apple_get_tax_class function when the radio button value is domestic. The form seems to be working fine however I can’t seem to get the variable into the big_apple function. I’ve also tried including the big_apple function within the kierans_vat_check and just doing the if from there but that wasn’t working either.

    Any help would be greatly appreciated.

    Thank you.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Changing tax with a radio button’ is closed to new replies.