WooCommerce Germanized - Version 1.6.5

Version Description

  • Fix - Direct Debit Encryption Class Loading (case-sensitive)
  • Fix - Customer Helper Fixes for Double Opt-In
  • Feature - Data Importer Update
Download this release

Release Info

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

Code changes from version 1.6.4 to 1.6.5

includes/admin/class-wc-gzd-admin-importer.php CHANGED
@@ -16,7 +16,8 @@ class WC_GZD_Admin_Importer {
16
 
17
  public $taxonomies = array(
18
  'product_delivery_time' => 'product_delivery_times',
19
- 'product_unit' => 'pa_masseinheit',
 
20
  );
21
 
22
  public static function instance() {
@@ -80,6 +81,9 @@ class WC_GZD_Admin_Importer {
80
 
81
  // Import delivery time
82
  $this->import_product_data();
 
 
 
83
 
84
  // Finished
85
  delete_option( '_wc_gzd_import_available' );
@@ -89,6 +93,41 @@ class WC_GZD_Admin_Importer {
89
  wp_safe_redirect( remove_query_arg( array( 'nonce', 'import' ) ) );
90
  }
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  private function import_settings() {
93
 
94
  $settings = array(
@@ -162,10 +201,7 @@ class WC_GZD_Admin_Importer {
162
 
163
  if ( $unit_term && ! is_wp_error( $unit_term ) ) {
164
 
165
- $gzd_term = false;
166
-
167
- if ( ! $gzd_term = get_term_by( 'slug', $unit, 'product_unit' ) )
168
- $gzd_term = wp_insert_term( $unit_term->name, 'product_unit', array( 'description' => $unit_term->description ) );
169
 
170
  if ( $gzd_term && ! is_wp_error( $gzd_term ) ) {
171
 
@@ -185,7 +221,20 @@ class WC_GZD_Admin_Importer {
185
 
186
  }
187
 
188
- // Delivery time
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  if ( $delivery_time = get_post_meta( $product->id, '_lieferzeit', true ) ) {
190
 
191
  $term = get_term_by( 'id', $delivery_time, $this->taxonomies[ 'product_delivery_time' ] );
@@ -207,6 +256,23 @@ class WC_GZD_Admin_Importer {
207
 
208
  }
209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  private function import_product_data() {
211
 
212
  // Temporarily add taxonomy if doesnt exist
16
 
17
  public $taxonomies = array(
18
  'product_delivery_time' => 'product_delivery_times',
19
+ 'product_unit' => 'pa_masseinheit',
20
+ 'product_price_label' => 'product_sale_labels',
21
  );
22
 
23
  public static function instance() {
81
 
82
  // Import delivery time
83
  $this->import_product_data();
84
+
85
+ // Import default delivery time/sale price label options
86
+ $this->import_defaults();
87
 
88
  // Finished
89
  delete_option( '_wc_gzd_import_available' );
93
  wp_safe_redirect( remove_query_arg( array( 'nonce', 'import' ) ) );
94
  }
95
 
96
+ private function import_defaults() {
97
+
98
+ $defaults = array(
99
+ 'product_delivery_time' => array(
100
+ 'org_option' => 'woocommerce_global_lieferzeit',
101
+ 'option' => 'woocommerce_gzd_default_delivery_time',
102
+ 'type' => 'id',
103
+ ),
104
+ 'product_price_label' => array(
105
+ 'org_option' => 'woocommerce_global_sale_label',
106
+ 'option' => 'woocommerce_gzd_default_sale_price_label',
107
+ 'type' => 'slug',
108
+ ),
109
+ );
110
+
111
+ foreach ( $defaults as $taxonomy => $options ) {
112
+
113
+ $default = get_option( $options[ 'org_option' ] );
114
+
115
+ if ( ! empty( $default ) ) {
116
+
117
+ $term = get_term_by( 'id', $default, $this->taxonomies[ $taxonomy ] );
118
+
119
+ if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
120
+
121
+ $gzd_term = $this->insert_term_if_necessary( $term, $taxonomy );
122
+
123
+ if ( ! empty( $gzd_term ) && ! is_wp_error( $gzd_term ) ) {
124
+ update_option( $options[ 'option' ], $options[ 'type' ] === 'slug' ? $gzd_term->slug : $gzd_term->term_id );
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+
131
  private function import_settings() {
132
 
133
  $settings = array(
201
 
202
  if ( $unit_term && ! is_wp_error( $unit_term ) ) {
203
 
204
+ $gzd_term = $this->insert_term_if_necessary( $unit_term, 'product_unit' );
 
 
 
205
 
206
  if ( $gzd_term && ! is_wp_error( $gzd_term ) ) {
207
 
221
 
222
  }
223
 
224
+ // Labels
225
+ if ( get_post_meta( $product->id, '_sale_label', true ) ) {
226
+
227
+ $term_id = get_post_meta( $product->id, '_sale_label', true );
228
+ $term = get_term_by( 'id', absint( $term_id ), $this->taxonomies[ 'product_price_label' ] );
229
+
230
+ if ( ! empty( $term ) && ! is_wp_error( $term ) ) {
231
+ $gzd_term = $this->insert_term_if_necessary( $term, 'product_price_label' );
232
+ $save['_sale_price_label'] = $term->slug;
233
+ }
234
+
235
+ }
236
+
237
+ // Delivery time (if does not exist will be added automatically)
238
  if ( $delivery_time = get_post_meta( $product->id, '_lieferzeit', true ) ) {
239
 
240
  $term = get_term_by( 'id', $delivery_time, $this->taxonomies[ 'product_delivery_time' ] );
256
 
257
  }
258
 
259
+ private function insert_term_if_necessary( $term, $taxonomy ) {
260
+
261
+ $gzd_term = false;
262
+
263
+ if ( ! $gzd_term = get_term_by( 'slug', $term->slug, $taxonomy ) ) {
264
+
265
+ $term_data = wp_insert_term( $term->name, $taxonomy, array( 'description' => $term->description ) );
266
+
267
+ if ( ! empty( $term_data ) && ! is_wp_error( $term_data ) ) {
268
+ $gzd_term = get_term_by( 'id', $term_data[ 'term_id' ], $taxonomy );
269
+ }
270
+ }
271
+
272
+ return $gzd_term;
273
+
274
+ }
275
+
276
  private function import_product_data() {
277
 
278
  // Temporarily add taxonomy if doesnt exist
includes/admin/meta-boxes/class-wc-gzd-meta-box-product-data.php CHANGED
@@ -185,7 +185,7 @@ class WC_Germanized_Meta_Box_Product_Data {
185
 
186
  if ( isset( $data[ 'delivery_time' ] ) && ! empty( $data[ 'delivery_time' ] ) ) {
187
  if ( ! is_numeric( $data[ 'delivery_time' ] ) )
188
- wp_set_post_terms( $post_id, sanitize_text_field( $data[ 'delivery_time' ] ), 'product_delivery_time' );
189
  else
190
  wp_set_object_terms( $post_id, absint( $data[ 'delivery_time' ] ) , 'product_delivery_time' );
191
  } else {
185
 
186
  if ( isset( $data[ 'delivery_time' ] ) && ! empty( $data[ 'delivery_time' ] ) ) {
187
  if ( ! is_numeric( $data[ 'delivery_time' ] ) )
188
+ wp_set_object_terms( $post_id, sanitize_text_field( $data[ 'delivery_time' ] ), 'product_delivery_time' );
189
  else
190
  wp_set_object_terms( $post_id, absint( $data[ 'delivery_time' ] ) , 'product_delivery_time' );
191
  } else {
includes/class-wc-gzd-customer-helper.php CHANGED
@@ -55,6 +55,8 @@ class WC_GZD_Customer_Helper {
55
  add_filter( 'woocommerce_login_redirect', array( $this, 'login_redirect' ), 10, 2 );
56
  // Disable customer signup if customer has forced guest checkout
57
  add_action( 'woocommerce_checkout_init', array( $this, 'disable_signup' ), 10, 1 );
 
 
58
  }
59
 
60
  }
@@ -69,6 +71,11 @@ class WC_GZD_Customer_Helper {
69
  return get_option( 'woocommerce_gzd_customer_activation_login_disabled' ) === 'yes';
70
  }
71
 
 
 
 
 
 
72
  public function disable_signup( $checkout ) {
73
 
74
  if ( WC()->session->get( 'disable_checkout_signup' ) )
@@ -101,6 +108,7 @@ class WC_GZD_Customer_Helper {
101
 
102
  WC()->session->set( 'login_redirect', 'checkout' );
103
  wp_safe_redirect( wc_gzd_get_page_permalink( 'myaccount' ) );
 
104
 
105
  } else if ( is_checkout() ) {
106
 
@@ -132,6 +140,7 @@ class WC_GZD_Customer_Helper {
132
 
133
  // Redirect to checkout
134
  wp_safe_redirect( wc_gzd_get_page_permalink( 'checkout' ) );
 
135
 
136
  }
137
 
55
  add_filter( 'woocommerce_login_redirect', array( $this, 'login_redirect' ), 10, 2 );
56
  // Disable customer signup if customer has forced guest checkout
57
  add_action( 'woocommerce_checkout_init', array( $this, 'disable_signup' ), 10, 1 );
58
+ // Remove the checkout signup cookie if customer logs out
59
+ add_action( 'wp_logout', array( $this, 'delete_checkout_signup_cookie' ) );
60
  }
61
 
62
  }
71
  return get_option( 'woocommerce_gzd_customer_activation_login_disabled' ) === 'yes';
72
  }
73
 
74
+ public function delete_checkout_signup_cookie() {
75
+ unset( WC()->session->disable_checkout_signup );
76
+ unset( WC()->session->login_redirect );
77
+ }
78
+
79
  public function disable_signup( $checkout ) {
80
 
81
  if ( WC()->session->get( 'disable_checkout_signup' ) )
108
 
109
  WC()->session->set( 'login_redirect', 'checkout' );
110
  wp_safe_redirect( wc_gzd_get_page_permalink( 'myaccount' ) );
111
+ exit;
112
 
113
  } else if ( is_checkout() ) {
114
 
140
 
141
  // Redirect to checkout
142
  wp_safe_redirect( wc_gzd_get_page_permalink( 'checkout' ) );
143
+ exit;
144
 
145
  }
146
 
includes/gateways/direct-debit/assets/js/direct-debit.min.js CHANGED
@@ -1 +1 @@
1
- !function(a){function b(a){return IBAN.isValid(a)}function c(a){var b=/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/;return b.test(a)}a(function(){a("form.checkout, form#order_review").on("blur input change","#direct-debit-form input#direct-debit-account-holder",function(){a(this).val()||(a(this).parents("p.form-row").removeClass("woocommerce-validated"),a(this).parents("p.form-row").addClass("woocommerce-invalid woocommerce-invalid-required-field"))}),a("form.checkout, form#order_review").on("blur input change","#direct-debit-form input#direct-debit-account-iban",function(){b(a(this).val())||(a(this).parents("p.form-row").removeClass("woocommerce-validated"),a(this).parents("p.form-row").addClass("woocommerce-invalid woocommerce-invalid-required-field"))}),a("form.checkout, form#order_review").on("blur input change","#direct-debit-form input#direct-debit-account-bic",function(){c(a(this).val())||(a(this).parents("p.form-row").removeClass("woocommerce-validated"),a(this).parents("p.form-row").addClass("woocommerce-invalid woocommerce-invalid-required-field"))}),a("form.checkout, form#order_review").on("blur input change","input, select",function(){a(".direct-debit-checkbox").hide(),a("#direct-debit-form").length&&a("#payment_method_direct-debit").is(":checked")&&a("input#direct-debit-account-holder").val()&&a("input#direct-debit-account-iban").val()&&a("input#direct-debit-account-bic").val()&&a(".direct-debit-checkbox").show()}),a(document).on("click","a#show-direct-debit-trigger",function(b){b.preventDefault();var c=a(this).attr("href"),d={country:a("#billing_country").val(),postcode:a("input#billing_postcode").val(),city:a("#billing_city").val(),address:a("input#billing_address_1").val(),address_2:a("input#billing_address_2").val(),debit_holder:a("input#direct-debit-account-holder").val(),debit_iban:a("input#direct-debit-account-iban").val(),debit_swift:a("input#direct-debit-account-bic").val()};c+="&ajax=true&"+jQuery.param(d),a("#show-direct-debit-pretty").attr("href",c),a("#show-direct-debit-pretty").trigger("click")}),a("a#show-direct-debit-pretty").prettyPhoto({social_tools:!1,theme:"pp_woocommerce",horizontal_padding:20,opacity:.8,deeplinking:!1})})}(jQuery);
1
+ !function(a){function b(a){return IBAN.isValid(a)}function c(a){var b=/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/;return b.test(a)}a(function(){a("form.checkout, form#order_review").on("blur input change","#direct-debit-form input#direct-debit-account-holder",function(){a(this).val()||(a(this).parents("p.form-row").removeClass("woocommerce-validated"),a(this).parents("p.form-row").addClass("woocommerce-invalid woocommerce-invalid-required-field"))}),a("form.checkout, form#order_review").on("blur input change","#direct-debit-form input#direct-debit-account-iban",function(){b(a(this).val())||(a(this).parents("p.form-row").removeClass("woocommerce-validated"),a(this).parents("p.form-row").addClass("woocommerce-invalid woocommerce-invalid-required-field"))}),a("form.checkout, form#order_review").on("blur input change","#direct-debit-form input#direct-debit-account-bic",function(){c(a(this).val())||(a(this).parents("p.form-row").removeClass("woocommerce-validated"),a(this).parents("p.form-row").addClass("woocommerce-invalid woocommerce-invalid-required-field"))}),a(".direct-debit-checkbox").hide(),a("form.checkout, form#order_review").on("blur input change","input, select",function(){a(".direct-debit-checkbox").hide(),a("#direct-debit-form").length&&a("#payment_method_direct-debit").is(":checked")&&a("input#direct-debit-account-holder").val()&&a("input#direct-debit-account-iban").val()&&a("input#direct-debit-account-bic").val()&&a(".direct-debit-checkbox").show()}),a(document).on("click","a#show-direct-debit-trigger",function(b){b.preventDefault();var c=a(this).attr("href"),d={country:a("#billing_country").val(),postcode:a("input#billing_postcode").val(),city:a("#billing_city").val(),address:a("input#billing_address_1").val(),address_2:a("input#billing_address_2").val(),debit_holder:a("input#direct-debit-account-holder").val(),debit_iban:a("input#direct-debit-account-iban").val(),debit_swift:a("input#direct-debit-account-bic").val()};c+="&ajax=true&"+jQuery.param(d),a("#show-direct-debit-pretty").attr("href",c),a("#show-direct-debit-pretty").trigger("click")}),a("a#show-direct-debit-pretty").prettyPhoto({social_tools:!1,theme:"pp_woocommerce",horizontal_padding:20,opacity:.8,deeplinking:!1})})}(jQuery);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: vendidero
3
  Tags: woocommerce, german market, german, germany, deutsch, deutschland, de, de_DE, shop, commerce, e-commerce, ecommerce, woothemes, sepa, invoice
4
  Requires at least: 3.8
5
  Tested up to: 4.5
6
- Stable tag: 1.6.4
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -157,6 +157,11 @@ Bug reports may be filed via our [GitHub repository](https://github.com/vendider
157
 
158
  == Changelog ==
159
 
 
 
 
 
 
160
  = 1.6.4 =
161
  * Fix - Encryption Library Classload fix
162
  * Feature - Encryption for Direct Debit Gateway data
3
  Tags: woocommerce, german market, german, germany, deutsch, deutschland, de, de_DE, shop, commerce, e-commerce, ecommerce, woothemes, sepa, invoice
4
  Requires at least: 3.8
5
  Tested up to: 4.5
6
+ Stable tag: 1.6.5
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
157
 
158
  == Changelog ==
159
 
160
+ = 1.6.5 =
161
+ * Fix - Direct Debit Encryption Class Loading (case-sensitive)
162
+ * Fix - Customer Helper Fixes for Double Opt-In
163
+ * Feature - Data Importer Update
164
+
165
  = 1.6.4 =
166
  * Fix - Encryption Library Classload fix
167
  * Feature - Encryption for Direct Debit Gateway data
woocommerce-germanized.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce Germanized
4
  * Plugin URI: https://www.vendidero.de/woocommerce-germanized
5
  * Description: Extends WooCommerce to become a legally compliant store for the german market.
6
- * Version: 1.6.4
7
  * Author: Vendidero
8
  * Author URI: https://vendidero.de
9
  * Requires at least: 3.8
@@ -26,7 +26,7 @@ final class WooCommerce_Germanized {
26
  *
27
  * @var string
28
  */
29
- public $version = '1.6.4';
30
 
31
  /**
32
  * Single instance of WooCommerce Germanized Main Class
@@ -223,6 +223,7 @@ final class WooCommerce_Germanized {
223
  public function autoload( $class ) {
224
 
225
  $path = $this->plugin_path() . '/includes/';
 
226
  $class = strtolower( $class );
227
  $file = 'class-' . str_replace( '_', '-', $class ) . '.php';
228
 
@@ -234,7 +235,7 @@ final class WooCommerce_Germanized {
234
  $path = $this->plugin_path() . '/includes/trusted-shops/';
235
  else if ( strpos( $class, 'defuse\crypto' ) !== false ) {
236
  $path = $this->plugin_path() . '/includes/gateways/direct-debit/libraries/php-encryption/';
237
- $file = ucfirst( str_replace( 'defuse/crypto/', '', str_replace( '\\', '/', $class ) ) . '.php' );
238
  }
239
 
240
  if ( $path && is_readable( $path . $file ) ) {
3
  * Plugin Name: WooCommerce Germanized
4
  * Plugin URI: https://www.vendidero.de/woocommerce-germanized
5
  * Description: Extends WooCommerce to become a legally compliant store for the german market.
6
+ * Version: 1.6.5
7
  * Author: Vendidero
8
  * Author URI: https://vendidero.de
9
  * Requires at least: 3.8
26
  *
27
  * @var string
28
  */
29
+ public $version = '1.6.5';
30
 
31
  /**
32
  * Single instance of WooCommerce Germanized Main Class
223
  public function autoload( $class ) {
224
 
225
  $path = $this->plugin_path() . '/includes/';
226
+ $original_class = $class;
227
  $class = strtolower( $class );
228
  $file = 'class-' . str_replace( '_', '-', $class ) . '.php';
229
 
235
  $path = $this->plugin_path() . '/includes/trusted-shops/';
236
  else if ( strpos( $class, 'defuse\crypto' ) !== false ) {
237
  $path = $this->plugin_path() . '/includes/gateways/direct-debit/libraries/php-encryption/';
238
+ $file = ucfirst( str_replace( 'Defuse/Crypto/', '', str_replace( '\\', '/', $original_class ) ) . '.php' );
239
  }
240
 
241
  if ( $path && is_readable( $path . $file ) ) {