wc_gzd_cart_totals_order_total_tax_html

Get order total tax html.

Description

wc_gzd_cart_totals_order_total_tax_html(); 

Usage

  1. if ( !function_exists( 'wc_gzd_cart_totals_order_total_tax_html' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-germanized/includes/wc-gzd-cart-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wc_gzd_cart_totals_order_total_tax_html(); 
  7.  

Defined (1)

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

/includes/wc-gzd-cart-functions.php  
  1. function wc_gzd_cart_totals_order_total_tax_html() { 
  2. $_tax = new WC_Tax(); 
  3. // If prices are tax inclusive, show taxes here 
  4. if ( get_option( 'woocommerce_calc_taxes' ) == 'yes' && WC()->cart->tax_display_cart == 'incl' ) { 
  5. $tax_array = array(); 
  6. if ( get_option( 'woocommerce_tax_total_display' ) == 'itemized' ) { 
  7. foreach ( WC()->cart->get_tax_totals() as $code => $tax ) { 
  8. $rate = wc_gzd_get_tax_rate( $tax->tax_rate_id ); 
  9. if ( ! $rate ) 
  10. continue; 
  11. if ( ! empty( $rate ) && isset( $rate->tax_rate ) ) 
  12. $tax->rate = $rate->tax_rate; 
  13. if ( ! isset( $tax_array[ $tax->rate ] ) ) 
  14. $tax_array[ $tax->rate ] = array( 'tax' => $tax, 'amount' => $tax->amount, 'contains' => array( $tax ) ); 
  15. else { 
  16. array_push( $tax_array[ $tax->rate ][ 'contains' ], $tax ); 
  17. $tax_array[ $tax->rate ][ 'amount' ] += $tax->amount; 
  18. } else { 
  19. $base_rate = array_values( WC_Tax::get_shop_base_rate() ); 
  20. $base_rate = (object) $base_rate[0]; 
  21. $base_rate->rate = $base_rate->rate; 
  22. $tax_array[] = array( 'tax' => $base_rate, 'contains' => array( $base_rate ), 'amount' => WC()->cart->get_taxes_total( true, true ) ); 
  23.  
  24. ?> 
  25.  
  26. <?php if ( ! empty( $tax_array ) ) : ?>  
  27.  
  28. <?php foreach ( $tax_array as $tax ) :  
  29.  
  30. $label = ( get_option( 'woocommerce_tax_total_display' ) == 'itemized' ? sprintf( __( 'incl. %s%% VAT', 'woocommerce-germanized' ), wc_gzd_format_tax_rate_percentage( $tax[ 'tax' ]->rate ) ) : __( 'incl. VAT', 'woocommerce-germanized' ) ); 
  31.  
  32. ?> 
  33. <tr class="order-tax"> 
  34. <th><?php echo $label; ?></th>  
  35. <td data-title="<?php echo esc_attr( $label ); ?>"><?php echo wc_price( $tax[ 'amount' ] ); ?></td> 
  36. </tr> 
  37.  
  38. <?php endforeach; ?> 
  39.  
  40. <?php endif;