/**
  * Whenever a WooCommerce tax rate is saved, also save the tax rate's hidden status.
  *
  * Executed whenever a WooCommerce tax rate is added, updated or deleted.
  *
  * @param int $tax_rate_id The WooCommerce Tax Rate ID.
  */
 public function save_tax_rate_hidden_status()
 {
     // nonce and cap checks are copied from WC_AJAX::tax_rates_save_changes()
     // Use return instead of exit so that WooCommerce core will handle the AJAX error messages
     if (!isset($_POST['wc_tax_nonce'], $_POST['changes'])) {
         return;
     }
     $current_class = !empty($_POST['current_class']) ? $_POST['current_class'] : '';
     // This is sanitized seven lines later.
     if (!wp_verify_nonce($_POST['wc_tax_nonce'], 'wc_tax_nonce-class:' . $current_class)) {
         return;
     }
     // Check User Caps
     if (!current_user_can('manage_woocommerce')) {
         return;
     }
     $hidden_rates = array();
     $current_class = WC_Tax::format_tax_rate_class($current_class);
     $rates = WC_Tax::get_rates_for_tax_class($current_class);
     foreach ($rates as $tax_rate_id => $rate) {
         if (isset($_POST['tax_rate_hidden'][$tax_rate_id])) {
             // @codingStandardsIgnoreEnd
             $hidden_rates[$tax_rate_id] = true;
         } else {
             if (isset($hidden_rates[$tax_rate_id])) {
                 unset($hidden_rates[$tax_rate_id]);
             }
         }
     }
     wc_hidden_taxes()->set_option('hidden_rates', $hidden_rates);
 }
 /**
  * Intercept whenever tax totals are displayed, and hide hidden tax rates from the customer.
  *
  * @param array            $tax_totals    Tax totals.
  * @param WC_Cart|WC_Order $cart_or_order Cart or order object.
  *
  * @return mixed
  */
 public function woocommerce_tax_totals($tax_totals, $cart_or_order)
 {
     if (is_admin()) {
         return $tax_totals;
     }
     foreach ($tax_totals as $key => $value) {
         if (wc_hidden_taxes()->is_hidden_tax_rate(isset($value->tax_rate_id) ? $value->tax_rate_id : $value->rate_id)) {
             unset($tax_totals[$key]);
         }
     }
     return $tax_totals;
 }
                $rate_id = intval($key_or_rate);
            }
            $hidden_rates = $this->get_hidden_tax_rates();
            if (isset($hidden_rates[$rate_id])) {
                return true;
            }
            return false;
        }
        /**
         * Get the list of hidden tax zones.
         * @return array
         */
        public function get_hidden_tax_rates()
        {
            return $this->get_option('hidden_rates');
        }
    }
    /**
     * This function should be used to access the WC_Hidden_Taxes singleton class.
     *
     * It's simpler to use this function instead of a global variable.
     *
     * @return WC_Hidden_Taxes
     */
    function wc_hidden_taxes()
    {
        return WC_Hidden_Taxes::instance();
    }
    // Let's get this thing started!
    wc_hidden_taxes();
}