Support » Plugins » Checking a variable in functions.php from external file

  • Hello,

    I’ve been looking through the forum but I haven’t managed to see anything that is helping. What I have is a function that changes tax rate for woocommerce on an if statement. See below

    // Woocommerce Commercial / Domestic VAT rate
    add_filter('woocommerce_product_tax_class', 'big_apple_get_tax_class', 1, 2);
    
    function big_apple_get_tax_class($tax_class, $product, $vat) {
       global $woocommerce;
    
       if ($woocommerce->cart->subtotal <= 110)
          $tax_class = 'Reduced Rate';
    
       return $tax_class;
    }

    What I need to do is change that if to:

    if ($vat == 1)
          $tax_class = 'Reduced Rate';
    
       return $tax_class;

    That $vat variable is stored in php file in the woocommerce directory, completely outside the functions.php file. Is there any way to get the value of that variable into the function at all? I’m trying to think of other ways to do this and didn’t know whether, in the woocommerce file, I could add an if saying

    if ($vat == 1)
        [load function]

    or something to that affect. Any help is greatly appreciated.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Checking a variable in functions.php from external file’ is closed to new replies.