WooCommerce Germanized - Version 2.2.11

Version Description

  • Fix: Tax share calculation in forced shipping rate
  • Fix: Mini cart hooks to show legal item data
Download this release

Release Info

Developer vendidero
Plugin Icon 128x128 WooCommerce Germanized
Version 2.2.11
Comparing to
See all releases

Code changes from version 2.2.10 to 2.2.11

includes/class-wc-gzd-shipping-rate.php CHANGED
@@ -4,8 +4,6 @@ class WC_GZD_Shipping_Rate extends WC_Shipping_Rate {
4
 
5
  public $tax_shares = array();
6
 
7
- protected $default_cost = 0;
8
-
9
  public function __construct( WC_Shipping_Rate $rate ) {
10
  $num = 5;
11
 
@@ -26,54 +24,55 @@ class WC_GZD_Shipping_Rate extends WC_Shipping_Rate {
26
  }
27
  }
28
 
29
- $this->default_cost = $rate->cost;
30
  $this->set_costs();
31
  }
32
 
33
- public function set_shared_taxes( $cart_contents = array() ) {
34
- $this->tax_shares = wc_gzd_get_cart_tax_share( 'shipping', $cart_contents );
 
35
 
36
- // Calculate tax class share
37
- if ( ! empty( $this->tax_shares ) ) {
38
-
39
- foreach ( $this->tax_shares as $rate => $class ) {
40
- $tax_rates = WC_Tax::get_rates( $rate );
41
- $this->tax_shares[ $rate ]['shipping_tax_share'] = $this->default_cost * $class[ 'share' ];
42
- $this->tax_shares[ $rate ]['shipping_tax'] = WC_Tax::calc_tax( ( $this->default_cost * $class[ 'share' ] ), $tax_rates, ( WC()->cart->tax_display_cart === 'incl' ) );
43
- }
44
-
45
- $taxes = array();
46
-
47
- foreach ( $this->tax_shares as $rate => $class ) {
48
- $taxes = array_map( 'wc_round_tax_total', $taxes + $class['shipping_tax'] );
49
- }
50
 
51
- if ( is_callable( array( $this, 'set_taxes' ) ) ) {
52
- $this->set_taxes( $taxes );
53
- } else {
54
- $this->taxes = $taxes;
55
- }
56
- }
57
- }
58
 
59
- public function set_costs() {
60
- if ( WC()->cart->tax_display_cart === 'incl' || WC()->customer->is_vat_exempt() ) {
61
- $cost = $this->default_cost - array_sum( $this->taxes );
62
 
63
- if ( WC()->customer->is_vat_exempt() ) {
64
- $shipping_rates = WC_Tax::get_shipping_tax_rates();
65
- $shipping_taxes = WC_Tax::calc_inclusive_tax( $this->cost, $shipping_rates );
66
- $cost = ( $cost - array_sum( $shipping_taxes ) );
67
- }
68
 
69
- if ( is_callable( array( $this, 'set_cost' ) ) ) {
70
- $this->set_cost( wc_format_decimal( $cost, wc_get_price_decimals() ) );
71
- } else {
72
- $this->cost = wc_format_decimal( $cost, wc_get_price_decimals() );
73
- }
74
- }
75
  }
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  public function get_shared_taxes() {
78
  return $this->taxes;
79
  }
4
 
5
  public $tax_shares = array();
6
 
 
 
7
  public function __construct( WC_Shipping_Rate $rate ) {
8
  $num = 5;
9
 
24
  }
25
  }
26
 
 
27
  $this->set_costs();
28
  }
29
 
30
+ public function set_shared_taxes() {
31
+ $cart = WC()->cart;
32
+ $this->tax_shares = wc_gzd_get_cart_tax_share();
33
 
34
+ // Calculate tax class share
35
+ if ( ! empty( $this->tax_shares ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ foreach ( $this->tax_shares as $rate => $class ) {
38
+ $tax_rates = WC_Tax::get_rates( $rate );
39
+ $this->tax_shares[ $rate ]['shipping_tax_share'] = $this->cost * $class[ 'share' ];
40
+ $this->tax_shares[ $rate ]['shipping_tax'] = WC_Tax::calc_tax( ( $this->cost * $class[ 'share' ] ), $tax_rates, ( WC()->cart->tax_display_cart === 'incl' ) );
41
+ }
 
 
42
 
43
+ $taxes = array();
 
 
44
 
45
+ foreach ( $this->tax_shares as $rate => $class ) {
46
+ $taxes = array_map( 'wc_round_tax_total', $taxes + $class['shipping_tax'] );
47
+ }
 
 
48
 
49
+ if ( is_callable( array( $this, 'set_taxes' ) ) ) {
50
+ $this->set_taxes( $taxes );
51
+ } else {
52
+ $this->taxes = $taxes;
53
+ }
54
+ }
55
  }
56
 
57
+ public function set_costs() {
58
+ if ( WC()->cart->tax_display_cart === 'incl' || WC()->customer->is_vat_exempt() ) {
59
+
60
+ $cost = $this->cost - array_sum( $this->taxes );
61
+
62
+ if ( WC()->customer->is_vat_exempt() ) {
63
+ $shipping_rates = WC_Tax::get_shipping_tax_rates();
64
+ $shipping_taxes = WC_Tax::calc_inclusive_tax( $this->cost, $shipping_rates );
65
+ $cost = ( $cost - array_sum( $shipping_taxes ) );
66
+ }
67
+
68
+ if ( is_callable( array( $this, 'set_cost' ) ) ) {
69
+ $this->set_cost( wc_format_decimal( $cost, wc_get_price_decimals() ) );
70
+ } else {
71
+ $this->cost = wc_format_decimal( $cost, wc_get_price_decimals() );
72
+ }
73
+ }
74
+ }
75
+
76
  public function get_shared_taxes() {
77
  return $this->taxes;
78
  }
includes/wc-gzd-cart-functions.php CHANGED
@@ -128,31 +128,33 @@ function wc_gzd_cart_product_attributes( $title, $cart_item, $cart_item_key = ''
128
  * @return string
129
  */
130
  function wc_gzd_cart_product_delivery_time( $title, $cart_item, $cart_item_key = '' ) {
131
-
132
  $delivery_time = "";
133
 
134
- if ( isset( $cart_item[ 'data' ] ) ) {
135
 
136
- $product = apply_filters( 'woocommerce_cart_item_product', $cart_item[ 'data' ], $cart_item, $cart_item_key );
137
 
138
- if ( wc_gzd_get_gzd_product( $product )->get_delivery_time_term() )
139
  $delivery_time = wc_gzd_get_gzd_product( $product )->get_delivery_time_html();
 
140
 
141
- } elseif ( isset( $cart_item[ 'delivery_time' ] ) ) {
142
 
143
- $delivery_time = $cart_item[ 'delivery_time' ];
144
 
145
- } elseif ( isset( $cart_item[ 'product_id' ] ) ) {
146
 
147
- $product = wc_get_product( ! empty( $cart_item[ 'variation_id' ] ) ? $cart_item[ 'variation_id' ] : $cart_item[ 'product_id' ] );
148
 
149
- if ( $product && wc_gzd_get_gzd_product( $product )->get_delivery_time_term() )
150
  $delivery_time = wc_gzd_get_gzd_product( $product )->get_delivery_time_html();
151
-
152
  }
153
 
154
- if ( ! empty( $delivery_time ) )
155
  $title .= '<p class="delivery-time-info">' . $delivery_time . '</p>';
 
156
 
157
  return $title;
158
  }
128
  * @return string
129
  */
130
  function wc_gzd_cart_product_delivery_time( $title, $cart_item, $cart_item_key = '' ) {
131
+
132
  $delivery_time = "";
133
 
134
+ if ( isset( $cart_item['data'] ) ) {
135
 
136
+ $product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
137
 
138
+ if ( wc_gzd_get_gzd_product( $product )->get_delivery_time_term() ) {
139
  $delivery_time = wc_gzd_get_gzd_product( $product )->get_delivery_time_html();
140
+ }
141
 
142
+ } elseif ( isset( $cart_item['delivery_time'] ) ) {
143
 
144
+ $delivery_time = $cart_item['delivery_time'];
145
 
146
+ } elseif ( isset( $cart_item['product_id'] ) ) {
147
 
148
+ $product = wc_get_product( ! empty( $cart_item['variation_id'] ) ? $cart_item['variation_id'] : $cart_item['product_id'] );
149
 
150
+ if ( $product && wc_gzd_get_gzd_product( $product )->get_delivery_time_term() ) {
151
  $delivery_time = wc_gzd_get_gzd_product( $product )->get_delivery_time_html();
152
+ }
153
  }
154
 
155
+ if ( ! empty( $delivery_time ) ) {
156
  $title .= '<p class="delivery-time-info">' . $delivery_time . '</p>';
157
+ }
158
 
159
  return $title;
160
  }
includes/wc-gzd-template-functions.php CHANGED
@@ -601,6 +601,11 @@ if ( ! function_exists( 'woocommerce_gzd_template_mini_cart_remove_hooks' ) ) {
601
  if ( ! function_exists( 'woocommerce_gzd_template_mini_cart_add_hooks' ) ) {
602
 
603
  function woocommerce_gzd_template_mini_cart_add_hooks() {
 
 
 
 
 
604
  add_filter( 'woocommerce_cart_item_name', 'wc_gzd_cart_product_units', wc_gzd_get_hook_priority( 'cart_product_units' ), 3 );
605
  add_filter( 'woocommerce_cart_item_name', 'wc_gzd_cart_product_delivery_time', wc_gzd_get_hook_priority( 'cart_product_delivery_time' ), 3 );
606
  add_filter( 'woocommerce_cart_item_name', 'wc_gzd_cart_product_item_desc', wc_gzd_get_hook_priority( 'cart_product_item_desc' ), 3 );
601
  if ( ! function_exists( 'woocommerce_gzd_template_mini_cart_add_hooks' ) ) {
602
 
603
  function woocommerce_gzd_template_mini_cart_add_hooks() {
604
+
605
+ if ( apply_filters( 'woocommerce_gzd_disable_mini_cart_item_legal_details', false ) ) {
606
+ return;
607
+ }
608
+
609
  add_filter( 'woocommerce_cart_item_name', 'wc_gzd_cart_product_units', wc_gzd_get_hook_priority( 'cart_product_units' ), 3 );
610
  add_filter( 'woocommerce_cart_item_name', 'wc_gzd_cart_product_delivery_time', wc_gzd_get_hook_priority( 'cart_product_delivery_time' ), 3 );
611
  add_filter( 'woocommerce_cart_item_name', 'wc_gzd_cart_product_item_desc', wc_gzd_get_hook_priority( 'cart_product_item_desc' ), 3 );
includes/wc-gzd-template-hooks.php CHANGED
@@ -94,8 +94,9 @@ if ( get_option( 'woocommerce_gzd_differential_taxation_checkout_notices' ) ===
94
  /**
95
  * Mini Cart
96
  */
97
- add_action( 'woocommerce_before_mini_cart', 'woocommerce_gzd_template_mini_cart_remove_hooks', 5 );
98
- add_action( 'woocommerce_after_mini_cart', 'woocommerce_gzd_template_mini_cart_add_hooks', 5 );
 
99
  add_action( 'woocommerce_widget_shopping_cart_before_buttons', 'woocommerce_gzd_template_mini_cart_taxes', 10 );
100
 
101
  /**
94
  /**
95
  * Mini Cart
96
  */
97
+ add_action( 'woocommerce_before_mini_cart_contents', 'woocommerce_gzd_template_mini_cart_remove_hooks', 5 );
98
+ add_action( 'woocommerce_before_mini_cart_contents', 'woocommerce_gzd_template_mini_cart_add_hooks', 10 );
99
+ add_action( 'woocommerce_after_mini_cart', 'woocommerce_gzd_template_mini_cart_remove_hooks', 10 );
100
  add_action( 'woocommerce_widget_shopping_cart_before_buttons', 'woocommerce_gzd_template_mini_cart_taxes', 10 );
101
 
102
  /**
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === WooCommerce Germanized ===
2
  Contributors: vendidero, vdwoocommercesupport
3
- Tags: woocommerce, woocommerce german, woocommerce DE, woocommerce germany, woocommerce deutsch, woo
4
  Requires at least: 3.8
5
  Tested up to: 5.1
6
  WC requires at least: 2.4
7
  WC tested up to: 3.6
8
- Stable tag: 2.2.10
9
  Requires PHP: 5.3
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -181,6 +181,10 @@ Bug reports may be filed via our [GitHub repository](https://github.com/vendider
181
 
182
  == Changelog ==
183
 
 
 
 
 
184
  = 2.2.10 =
185
  * Feature: WC 3.6 compatibility
186
  * Improvement: By default mark post_number as non-required for better gateway compatibility
1
  === WooCommerce Germanized ===
2
  Contributors: vendidero, vdwoocommercesupport
3
+ Tags: woocommerce, woocommerce german, woocommerce DE, woocommerce germany, woocommerce deutsch, woo, woocommerce deutschland, woocommerce germanized, woocommerce addon, woocommerce plugin, woocommerce german addon, woocommerce germany addon
4
  Requires at least: 3.8
5
  Tested up to: 5.1
6
  WC requires at least: 2.4
7
  WC tested up to: 3.6
8
+ Stable tag: 2.2.11
9
  Requires PHP: 5.3
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
181
 
182
  == Changelog ==
183
 
184
+ = 2.2.11 =
185
+ * Fix: Tax share calculation in forced shipping rate
186
+ * Fix: Mini cart hooks to show legal item data
187
+
188
  = 2.2.10 =
189
  * Feature: WC 3.6 compatibility
190
  * Improvement: By default mark post_number as non-required for better gateway compatibility
woocommerce-germanized.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce Germanized
4
  * Plugin URI: https://www.vendidero.de/woocommerce-germanized
5
  * Description: WooCommerce Germanized extends WooCommerce to become a legally compliant store in the german market.
6
- * Version: 2.2.10
7
  * Author: Vendidero
8
  * Author URI: https://vendidero.de
9
  * Requires at least: 3.8
@@ -31,7 +31,7 @@ final class WooCommerce_Germanized {
31
  *
32
  * @var string
33
  */
34
- public $version = '2.2.10';
35
 
36
  /**
37
  * Single instance of WooCommerce Germanized Main Class
3
  * Plugin Name: WooCommerce Germanized
4
  * Plugin URI: https://www.vendidero.de/woocommerce-germanized
5
  * Description: WooCommerce Germanized extends WooCommerce to become a legally compliant store in the german market.
6
+ * Version: 2.2.11
7
  * Author: Vendidero
8
  * Author URI: https://vendidero.de
9
  * Requires at least: 3.8
31
  *
32
  * @var string
33
  */
34
+ public $version = '2.2.11';
35
 
36
  /**
37
  * Single instance of WooCommerce Germanized Main Class