The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] Changing tax with a radio button (2 posts)

  1. Kieran McClung
    Posted 2 years ago #

    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.


  2. Kieran McClung
    Posted 2 years ago #

    It appears I over-complicated this. Variable product has worked just fine for this.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic