WC_GZD_Compatibility_Woocommerce_Subscriptions

WPML Helper.

Defined (1)

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

/includes/compatibility/class-wc-gzd-compatibility-woocommerce-subscriptions.php  
  1. class WC_GZD_Compatibility_Woocommerce_Subscriptions extends WC_GZD_Compatibility { 
  2.  
  3. public function __construct() { 
  4.  
  5. parent::__construct(  
  6. 'WooCommerce Subscriptions',  
  7. 'woocommerce-subscriptions/woocommerce-subscriptions.php',  
  8. array( 
  9. 'version' => get_option( 'woocommerce_subscriptions_active_version', '1.0.0' ),  
  10. 'requires_at_least' => '2.0',  
  11. ); 
  12.  
  13.  
  14. public function load() { 
  15. add_filter( 'wcs_cart_totals_order_total_html', array( $this, 'set_tax_notice' ), 50, 2 ); 
  16.  
  17. public function set_tax_notice( $price, $cart ) { 
  18. ob_start(); 
  19.  
  20. // Tax for inclusive prices 
  21. if ( 'yes' == get_option( 'woocommerce_calc_taxes' ) && 'incl' == $cart->tax_display_cart ) { 
  22.  
  23. $tax_array = array(); 
  24.  
  25. if ( 'itemized' == get_option( 'woocommerce_tax_total_display' ) ) { 
  26. foreach ( $cart->get_tax_totals() as $code => $tax ) { 
  27. $rate = wc_gzd_get_tax_rate( $tax->tax_rate_id ); 
  28. if ( ! $rate ) 
  29. continue; 
  30. if ( ! empty( $rate ) && isset( $rate->tax_rate ) ) 
  31. $tax->rate = $rate->tax_rate; 
  32. if ( ! isset( $tax_array[ $tax->rate ] ) ) 
  33. $tax_array[ $tax->rate ] = array( 'tax' => $tax, 'amount' => $tax->amount, 'contains' => array( $tax ) ); 
  34. else { 
  35. array_push( $tax_array[ $tax->rate ][ 'contains' ], $tax ); 
  36. $tax_array[ $tax->rate ][ 'amount' ] += $tax->amount; 
  37. } else { 
  38. $base_rate = array_values( WC_Tax::get_shop_base_rate() ); 
  39. $base_rate = (object) $base_rate[0]; 
  40. $base_rate->rate = $base_rate->rate; 
  41. $tax_array[] = array( 'tax' => $base_rate, 'contains' => array( $base_rate ), 'amount' => $cart->get_taxes_total( true, true ) ); 
  42.  
  43. ?> 
  44.  
  45. <?php echo $price; ?> 
  46. </td></tr> 
  47.  
  48. <?php 
  49.  
  50. if ( ! empty( $tax_array ) ) { 
  51.  
  52. $count = 0; 
  53. foreach ( $tax_array as $tax ) { 
  54.  
  55. $count++; 
  56. $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' ) ); 
  57. ?> 
  58.  
  59. <tr class="order-tax"> 
  60. <th rowspan="1"><?php echo $label; ?></th> 
  61. <td data-title="<?php echo esc_attr( $label ); ?>"><?php echo wc_price( $tax[ 'amount' ] ); ?> 
  62.  
  63. <?php if ( sizeof( $tax_array ) != $count ) : ?> 
  64. </td></tr> 
  65. <?php endif; ?> 
  66.  
  67. <?php 
  68. return ob_get_clean(); 
  69.