WC_POS_Tax

POS Tax Class.

Defined (1)

The class is defined in the following location(s).

/includes/class-wc-pos-tax.php  
  1. class WC_POS_Tax { 
  2.  
  3. /** 
  4. * Returns all tax classes, class => label 
  5. * @return array 
  6. */ 
  7. static public function tax_classes() { 
  8. $classes = array( 
  9. /** translators: woocommerce */ 
  10. '' => __( 'Standard', 'woocommerce' ) 
  11. ); 
  12.  
  13. // get_tax_classes method introduced in WC 2.3 
  14. if( method_exists( 'WC_Tax', 'get_tax_classes' ) ) { 
  15. $labels = WC_Tax::get_tax_classes(); 
  16. } else { 
  17. $labels = array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ) ); 
  18.  
  19. foreach( $labels as $label ) { 
  20. $classes[ sanitize_title($label) ] = $label; 
  21.  
  22. return $classes; 
  23.  
  24. /** 
  25. * Returns base tax rates for all tax classes 
  26. * @return array 
  27. */ 
  28. static public function tax_rates() { 
  29. $rates = array(); 
  30.  
  31. foreach( self::tax_classes() as $class => $label ) { 
  32. if( $rate = WC_Tax::get_base_tax_rates( $class ) ) { 
  33. // WC_Tax returns a assoc array with int as keys = world of pain in js 
  34. // possibly change $key to $rate['id'] 
  35. $rates[$class] = $rate; 
  36.  
  37. return $rates; 
  38.