WC_GZD_Shipping_Rate

The WooCommerce Germanized WC GZD Shipping Rate class.

Defined (1)

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

/includes/class-wc-gzd-shipping-rate.php  
  1. class WC_GZD_Shipping_Rate extends WC_Shipping_Rate { 
  2.  
  3. public $tax_shares = array(); 
  4.  
  5. public function __construct( WC_Shipping_Rate $rate ) { 
  6. parent::__construct( $rate->id, $rate->label, $rate->cost, $rate->taxes, $rate->method_id ); 
  7.  
  8. if ( get_option( 'woocommerce_gzd_shipping_tax' ) === 'yes' && ( ! empty( $rate->taxes ) || get_option( 'woocommerce_gzd_shipping_tax_force' ) === 'yes' ) ) 
  9. $this->set_taxes(); 
  10.  
  11. $this->set_costs(); 
  12.  
  13. public function set_taxes() { 
  14.  
  15. $cart = WC()->cart; 
  16. $this->tax_shares = wc_gzd_get_cart_tax_share(); 
  17.  
  18. // Calculate tax class share 
  19. if ( ! empty( $this->tax_shares ) ) { 
  20.  
  21. foreach ( $this->tax_shares as $rate => $class ) { 
  22. $tax_rates = WC_Tax::get_rates( $rate ); 
  23. $this->tax_shares[ $rate ][ 'shipping_tax_share' ] = $this->cost * $class[ 'share' ]; 
  24. $this->tax_shares[ $rate ][ 'shipping_tax' ] = WC_Tax::calc_tax( ( $this->cost * $class[ 'share' ] ), $tax_rates, true ); 
  25.  
  26. $this->taxes = array(); 
  27.  
  28. foreach ( $this->tax_shares as $rate => $class ) { 
  29. $this->taxes = $this->taxes + $class[ 'shipping_tax' ]; 
  30.  
  31. public function set_costs() { 
  32. $this->cost = $this->cost - array_sum( $this->taxes ); 
  33.  
  34. public function get_taxes() { 
  35. return $this->taxes; 
  36.