WC_Tax::is_compound PHP Method

is_compound() public static method

Return true/false depending on if a rate is a compound rate.
public static is_compound ( $key ) : boolean
return boolean
    public static function is_compound($key)
    {
        global $wpdb;
        return $wpdb->get_var($wpdb->prepare("SELECT tax_rate_compound FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key)) ? true : false;
    }

Usage Example

Example #1
0
 /**
  * Get tax row amounts with or without compound taxes includes.
  *
  * @return float price
  */
 public function get_taxes_total($compound = true)
 {
     $total = 0;
     foreach ($this->taxes as $key => $tax) {
         if (!$compound && $this->tax->is_compound($key)) {
             continue;
         }
         $total += $tax;
     }
     foreach ($this->shipping_taxes as $key => $tax) {
         if (!$compound && $this->tax->is_compound($key)) {
             continue;
         }
         $total += $tax;
     }
     return $total;
 }
All Usage Examples Of WC_Tax::is_compound