WooCommerce Multilingual – run WooCommerce with WPML - Version 3.7.6

Version Description

  • Fixed several problems with the permalinks when using the slash character in the bases
  • Fixed an issue with coupons: the coupons were not applied according to the minimum amount of the cart in the current currency
  • Fixed one compatibility issue with the Flatsome theme
  • Fixed a bug preventing the shop page link to be translated correctly to the other languages (when using WPML 3.3.1+)
Download this release

Release Info

Developer mihaimihai
Plugin Icon 128x128 WooCommerce Multilingual – run WooCommerce with WPML
Version 3.7.6
Comparing to
See all releases

Code changes from version 3.7.5 to 3.7.6

compatibility/class-wcml-flatsome.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WCML_Flatsome{
4
+
5
+ function __construct(){
6
+ add_filter( 'wcml_multi_currency_is_ajax', array( $this, 'add_action_to_multi_currency_ajax' ) );
7
+ }
8
+
9
+ function add_action_to_multi_currency_ajax($actions){
10
+ $actions[] = 'ux_quickview';
11
+ return $actions;
12
+ }
13
+
14
+
15
+ }
16
+
inc/compatibility.class.php CHANGED
@@ -106,6 +106,12 @@ class WCML_Compatibility {
106
  $this->wc_checkout_addons = new WCML_Checkout_Addons();
107
  }
108
 
 
 
 
 
 
 
109
  }
110
 
111
  function autoload( $class ){
106
  $this->wc_checkout_addons = new WCML_Checkout_Addons();
107
  }
108
 
109
+ // woocommerce checkout addons
110
+ if ( wp_get_theme() == 'Flatsome' ) {
111
+ $this->flatsome = new WCML_Flatsome();
112
+ }
113
+
114
+
115
  }
116
 
117
  function autoload( $class ){
inc/functions-troubleshooting.class.php CHANGED
@@ -216,6 +216,9 @@ class WCML_Troubleshooting{
216
  $term_name = $term->name.' @'.$language['code'];
217
  }else{
218
  $term_name = $term->name;
 
 
 
219
  }
220
 
221
  $new_term = wp_insert_term( $term_name , $attr, $term_args );
216
  $term_name = $term->name.' @'.$language['code'];
217
  }else{
218
  $term_name = $term->name;
219
+ $slug = $term->name.'-'.$language['code'];
220
+ $slug = WPML_Terms_Translations::term_unique_slug( $slug, $attr, $language['code'] );
221
+ $term_args[ 'slug' ] = $slug;
222
  }
223
 
224
  $new_term = wp_insert_term( $term_name , $attr, $term_args );
inc/multi-currency-support.class.php CHANGED
@@ -70,7 +70,7 @@ class WCML_Multi_Currency_Support{
70
  }
71
 
72
  function init(){
73
-
74
  if($this->_load_filters()){
75
 
76
  add_filter('woocommerce_currency', array($this, 'currency_filter'));
@@ -78,7 +78,7 @@ class WCML_Multi_Currency_Support{
78
 
79
  add_filter('get_post_metadata', array($this, 'product_price_filter'), 10, 4);
80
  add_filter('get_post_metadata', array($this, 'variation_prices_filter'), 12, 4); // second
81
-
82
  add_filter('woocommerce_package_rates', array($this, 'shipping_taxes_filter'));
83
 
84
  add_action('woocommerce_coupon_loaded', array($this, 'filter_coupon_data'));
@@ -125,6 +125,7 @@ class WCML_Multi_Currency_Support{
125
  if(!is_admin()) $this->load_inline_js();
126
 
127
  add_action( 'woocommerce_get_children', array( $this, 'filter_product_variations_with_custom_prices' ), 10 );
 
128
 
129
  }
130
 
@@ -991,7 +992,7 @@ class WCML_Multi_Currency_Support{
991
  return $custom_prices;
992
 
993
  }
994
-
995
  function currency_filter($currency){
996
 
997
  $currency = apply_filters('wcml_price_currency', $currency);
@@ -1073,10 +1074,12 @@ class WCML_Multi_Currency_Support{
1073
  function filter_coupon_data($coupon){
1074
 
1075
  if($coupon->type == 'fixed_cart' || $coupon->type == 'fixed_product'){
1076
- $coupon->amount = apply_filters('wcml_raw_price_amount', $coupon->amount);
1077
  }
1078
-
1079
-
 
 
1080
  }
1081
 
1082
  function get_client_currency(){
70
  }
71
 
72
  function init(){
73
+
74
  if($this->_load_filters()){
75
 
76
  add_filter('woocommerce_currency', array($this, 'currency_filter'));
78
 
79
  add_filter('get_post_metadata', array($this, 'product_price_filter'), 10, 4);
80
  add_filter('get_post_metadata', array($this, 'variation_prices_filter'), 12, 4); // second
81
+
82
  add_filter('woocommerce_package_rates', array($this, 'shipping_taxes_filter'));
83
 
84
  add_action('woocommerce_coupon_loaded', array($this, 'filter_coupon_data'));
125
  if(!is_admin()) $this->load_inline_js();
126
 
127
  add_action( 'woocommerce_get_children', array( $this, 'filter_product_variations_with_custom_prices' ), 10 );
128
+
129
 
130
  }
131
 
992
  return $custom_prices;
993
 
994
  }
995
+
996
  function currency_filter($currency){
997
 
998
  $currency = apply_filters('wcml_price_currency', $currency);
1074
  function filter_coupon_data($coupon){
1075
 
1076
  if($coupon->type == 'fixed_cart' || $coupon->type == 'fixed_product'){
1077
+ $coupon->amount = apply_filters('wcml_raw_price_amount', $coupon->amount);
1078
  }
1079
+
1080
+ $coupon->minimum_amount = apply_filters('wcml_raw_price_amount', $coupon->minimum_amount);
1081
+ $coupon->maximum_amount = apply_filters('wcml_raw_price_amount', $coupon->maximum_amount);
1082
+
1083
  }
1084
 
1085
  function get_client_currency(){
inc/products.class.php CHANGED
@@ -918,12 +918,12 @@ class WCML_Products{
918
  $duplicated_id = apply_filters( 'translate_object_id', $image_id, 'attachment', false, $translation->language_code );
919
  if ( is_null( $duplicated_id ) && $image_id ) {
920
 
921
- $duplicated_id = WPML_media::create_duplicate_attachment( $image_id, wp_get_post_parent_id( $image_id ), $translation->language_code );
922
  }
923
  $duplicated_ids .= $duplicated_id . ',';
924
  }
925
  }
926
- $duplicated_ids = substr( $duplicated_ids, 0, strlen( $duplicated_ids )-1 );
927
  update_post_meta( $translation->element_id, '_product_image_gallery', $duplicated_ids );
928
  }
929
  }
@@ -1312,7 +1312,7 @@ class WCML_Products{
1312
  $thumbnail_id = get_post_meta( $orig_post_id, '_thumbnail_id', true );
1313
  $trnsl_thumbnail = apply_filters( 'translate_object_id', $thumbnail_id, 'attachment', false, $lang );
1314
  if( is_null( $trnsl_thumbnail ) && $thumbnail_id ){
1315
- $trnsl_thumbnail = WPML_media::create_duplicate_attachment( $thumbnail_id, wp_get_post_parent_id( $thumbnail_id ), $lang );
1316
  }
1317
 
1318
  update_post_meta( $trnsl_post_id, '_thumbnail_id', $trnsl_thumbnail );
@@ -2479,8 +2479,8 @@ class WCML_Products{
2479
 
2480
  function remove_language_options(){
2481
  global $WPML_media,$typenow;
2482
- if(defined('WPML_MEDIA_VERSION') && $typenow == 'product'){
2483
- remove_action('icl_post_languages_options_after',array($WPML_media,'language_options'));
2484
  add_action( 'icl_post_languages_options_after', array( $this, 'media_inputs' ) );
2485
  }
2486
  }
918
  $duplicated_id = apply_filters( 'translate_object_id', $image_id, 'attachment', false, $translation->language_code );
919
  if ( is_null( $duplicated_id ) && $image_id ) {
920
 
921
+ $duplicated_id = WPML_Media::create_duplicate_attachment( $image_id, wp_get_post_parent_id( $image_id ), $translation->language_code );
922
  }
923
  $duplicated_ids .= $duplicated_id . ',';
924
  }
925
  }
926
+ $duplicated_ids = substr( $duplicated_ids, 0, strlen( $duplicated_ids ) - 1 );
927
  update_post_meta( $translation->element_id, '_product_image_gallery', $duplicated_ids );
928
  }
929
  }
1312
  $thumbnail_id = get_post_meta( $orig_post_id, '_thumbnail_id', true );
1313
  $trnsl_thumbnail = apply_filters( 'translate_object_id', $thumbnail_id, 'attachment', false, $lang );
1314
  if( is_null( $trnsl_thumbnail ) && $thumbnail_id ){
1315
+ $trnsl_thumbnail = WPML_Media::create_duplicate_attachment( $thumbnail_id, wp_get_post_parent_id( $thumbnail_id ), $lang );
1316
  }
1317
 
1318
  update_post_meta( $trnsl_post_id, '_thumbnail_id', $trnsl_thumbnail );
2479
 
2480
  function remove_language_options(){
2481
  global $WPML_media,$typenow;
2482
+ if( defined('WPML_MEDIA_VERSION') && $typenow == 'product'){
2483
+ remove_action('icl_post_languages_options_after',array( $WPML_media,'language_options'));
2484
  add_action( 'icl_post_languages_options_after', array( $this, 'media_inputs' ) );
2485
  }
2486
  }
inc/store-pages.class.php CHANGED
@@ -231,18 +231,23 @@ class WCML_Store_Pages{
231
  global $sitepress;
232
  $shop_id = $this->shop_page_id;
233
  $front_id = apply_filters( 'translate_object_id',$this->front_page_id, 'page');
234
- foreach ($languages as &$language) {
 
235
  // shop page
236
  // obsolete?
237
  if (is_post_type_archive('product')) {
238
  if ($front_id == $shop_id) {
239
  $url = $sitepress->language_url($language['language_code']);
240
  } else {
241
- $url = get_permalink(apply_filters( 'translate_object_id',$shop_id, 'page', true, $language['language_code']));
 
 
242
  }
243
- $language['url'] = $url;
 
244
  }
245
  }
 
246
  return $languages;
247
  }
248
 
231
  global $sitepress;
232
  $shop_id = $this->shop_page_id;
233
  $front_id = apply_filters( 'translate_object_id',$this->front_page_id, 'page');
234
+
235
+ foreach ($languages as $language) {
236
  // shop page
237
  // obsolete?
238
  if (is_post_type_archive('product')) {
239
  if ($front_id == $shop_id) {
240
  $url = $sitepress->language_url($language['language_code']);
241
  } else {
242
+ $sitepress->switch_lang($language['language_code']);
243
+ $url = get_permalink( apply_filters( 'translate_object_id', $shop_id, 'page', true, $language['language_code']) );
244
+ $sitepress->switch_lang();
245
  }
246
+
247
+ $languages[$language['language_code']]['url'] = $url;
248
  }
249
  }
250
+
251
  return $languages;
252
  }
253
 
inc/url-translation.class.php CHANGED
@@ -20,8 +20,7 @@ class WCML_Url_Translation {
20
 
21
  add_filter( 'pre_update_option_rewrite_rules', array( $this, 'force_bases_in_strings_languages' ), 1, 1 ); // high priority
22
 
23
- remove_filter( 'option_rewrite_rules', array( 'WPML_Slug_Translation', 'rewrite_rules_filter' ), 1, 1 ); //remove filter from WPML and use WCML filter first
24
- add_filter( 'option_rewrite_rules', array( $this, 'translate_bases_in_rewrite_rules' ), 3, 1 ); // high priority
25
 
26
  add_filter( 'term_link', array( $this, 'translate_taxonomy_base' ), 0, 3 ); // high priority
27
 
@@ -342,10 +341,6 @@ class WCML_Url_Translation {
342
  function translate_bases_in_rewrite_rules( $value ) {
343
  global $sitepress, $sitepress_settings, $woocommerce_wpml;
344
 
345
- if ( !empty( $sitepress_settings['posts_slug_translation']['on'] ) ) {
346
- add_filter( 'option_rewrite_rules', array( 'WPML_Slug_Translation', 'rewrite_rules_filter' ), 1, 1 );
347
- }
348
-
349
  $cache_key = 'wcml_rewrite_filters_translate_taxonomies';
350
 
351
  if ( $val = wp_cache_get( $cache_key ) ) {
@@ -358,17 +353,24 @@ class WCML_Url_Translation {
358
 
359
  foreach ( $taxonomies as $taxonomy ) {
360
  $slug_details = $this->get_translated_tax_slug( $taxonomy );
 
361
  $string_language = $woocommerce_wpml->strings->get_string_language( $slug_details['slug'], $this->url_strings_context(), $this->url_string_name( $taxonomy ) );
362
  if ( $sitepress->get_current_language() == $string_language ) {
363
  continue;
364
  }
365
 
366
  if ( $slug_details ) {
 
 
 
 
367
  $buff_value = array();
368
  foreach ( (array)$value as $k => $v ) {
369
- if ( $slug_details['slug'] != $slug_details['translated_slug'] && preg_match( '#^[^/]*/?' . $slug_details['slug'] . '/#', $k ) ) {
370
- $k = preg_replace( '#^([^/]*)(/?)' . $slug_details['slug'] . '/#', '$1$2' . $slug_details['translated_slug'] . '/', $k );
 
371
  }
 
372
  $buff_value[$k] = $v;
373
  }
374
  $value = $buff_value;
@@ -400,10 +402,13 @@ class WCML_Url_Translation {
400
  $slug_translation = apply_filters('wpml_translate_single_string', $slug, $this->url_strings_context(), $this->url_string_name( 'attribute' ) );
401
  if ($slug_translation) {
402
 
 
 
 
403
  $buff_value = array();
404
  foreach ((array)$value as $k => $v) {
405
- if ($slug != $slug_translation && preg_match('#^' . $slug . '/(.*)#', $k)) {
406
- $k = preg_replace('#^' . $slug . '/(.*)#', $slug_translation . '/$1', $k);
407
  }
408
  $buff_value[$k] = $v;
409
  }
@@ -432,7 +437,7 @@ class WCML_Url_Translation {
432
 
433
  } else {
434
 
435
- $current_shop_id = woocommerce_get_page_id( 'shop' );
436
  $default_shop_id = apply_filters( 'translate_object_id', $current_shop_id, 'page', true, $sitepress->get_default_language() );
437
 
438
  if ( is_null( get_post( $current_shop_id ) ) || is_null( get_post( $default_shop_id ) ) )
@@ -441,13 +446,17 @@ class WCML_Url_Translation {
441
  $current_slug = get_post( $current_shop_id )->post_name;
442
  $default_slug = get_post( $default_shop_id )->post_name;
443
 
444
-
445
  if ( $current_slug != $default_slug ) {
446
  $buff_value = array();
447
  foreach ( (array)$value as $k => $v ) {
448
- if ( $current_slug != $default_slug && preg_match( '#^[^/]*/?' . $default_slug . '/page/#', $k ) ) {
449
- $k = preg_replace( '#^([^/]*)(/?)' . $default_slug . '/#', '$1$2' . $current_slug . '/', $k );
 
 
 
 
450
  }
 
451
  $buff_value[$k] = $v;
452
  }
453
 
20
 
21
  add_filter( 'pre_update_option_rewrite_rules', array( $this, 'force_bases_in_strings_languages' ), 1, 1 ); // high priority
22
 
23
+ add_filter( 'option_rewrite_rules', array( $this, 'translate_bases_in_rewrite_rules' ), 0, 1 ); // high priority
 
24
 
25
  add_filter( 'term_link', array( $this, 'translate_taxonomy_base' ), 0, 3 ); // high priority
26
 
341
  function translate_bases_in_rewrite_rules( $value ) {
342
  global $sitepress, $sitepress_settings, $woocommerce_wpml;
343
 
 
 
 
 
344
  $cache_key = 'wcml_rewrite_filters_translate_taxonomies';
345
 
346
  if ( $val = wp_cache_get( $cache_key ) ) {
353
 
354
  foreach ( $taxonomies as $taxonomy ) {
355
  $slug_details = $this->get_translated_tax_slug( $taxonomy );
356
+
357
  $string_language = $woocommerce_wpml->strings->get_string_language( $slug_details['slug'], $this->url_strings_context(), $this->url_string_name( $taxonomy ) );
358
  if ( $sitepress->get_current_language() == $string_language ) {
359
  continue;
360
  }
361
 
362
  if ( $slug_details ) {
363
+
364
+ $slug_match = addslashes( ltrim($slug_details['slug'], '/') );
365
+ $slug_translation_match = ltrim($slug_details['translated_slug'], '/');
366
+
367
  $buff_value = array();
368
  foreach ( (array)$value as $k => $v ) {
369
+
370
+ if ( $slug_details['slug'] != $slug_details['translated_slug'] && preg_match( '#^[^/]*/?' . $slug_match . '/#', $k ) ) {
371
+ $k = preg_replace( '#^([^/]*)(/?)' . $slug_match . '/#', '$1$2' . $slug_translation_match . '/', $k );
372
  }
373
+
374
  $buff_value[$k] = $v;
375
  }
376
  $value = $buff_value;
402
  $slug_translation = apply_filters('wpml_translate_single_string', $slug, $this->url_strings_context(), $this->url_string_name( 'attribute' ) );
403
  if ($slug_translation) {
404
 
405
+ $slug_match = addslashes( ltrim($slug, '/') );
406
+ $slug_translation_match = ltrim($slug_translation, '/');
407
+
408
  $buff_value = array();
409
  foreach ((array)$value as $k => $v) {
410
+ if ($slug != $slug_translation && preg_match('#^' . $slug_match . '/(.*)#', $k)) {
411
+ $k = preg_replace('#^' . $slug_match . '/(.*)#', $slug_translation_match . '/$1', $k);
412
  }
413
  $buff_value[$k] = $v;
414
  }
437
 
438
  } else {
439
 
440
+ $current_shop_id = wc_get_page_id( 'shop' );
441
  $default_shop_id = apply_filters( 'translate_object_id', $current_shop_id, 'page', true, $sitepress->get_default_language() );
442
 
443
  if ( is_null( get_post( $current_shop_id ) ) || is_null( get_post( $default_shop_id ) ) )
446
  $current_slug = get_post( $current_shop_id )->post_name;
447
  $default_slug = get_post( $default_shop_id )->post_name;
448
 
 
449
  if ( $current_slug != $default_slug ) {
450
  $buff_value = array();
451
  foreach ( (array)$value as $k => $v ) {
452
+
453
+ if( preg_match( '#^' . $default_slug . '/\?\$$#', $k ) ||
454
+ preg_match( '#^' . $default_slug . '/\(?feed#', $k ) ||
455
+ preg_match( '#^' . $default_slug . '/page#', $k )){
456
+
457
+ $k = preg_replace( '#^' . $default_slug . '/#', $current_slug . '/', $k );
458
  }
459
+
460
  $buff_value[$k] = $v;
461
  }
462
 
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: http://wpml.org/documentation/related-projects/woocommerce-multilin
4
  Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multilingual, e-shop, shop
5
  License: GPLv2
6
  Requires at least: 3.0
7
- Tested up to: 4.3.1
8
- Stable tag: 3.7.5
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
@@ -78,6 +78,13 @@ In order for the checkout and store pages to appear translated, you need to crea
78
 
79
  == Changelog ==
80
 
 
 
 
 
 
 
 
81
  = 3.7.5 =
82
  * Fixed a backward compatibility with WPML versions prior 3.2 (causing fatal error)
83
  * Bug fix: in some specific cases variations were not created correctly - 'Any %name%' instead of term value
@@ -614,4 +621,4 @@ Fixed a few bugs. Added multi-currency mode.
614
  Recommended update! Fixed a few bugs;
615
 
616
  = 0.9 =
617
- * First release
4
  Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multilingual, e-shop, shop
5
  License: GPLv2
6
  Requires at least: 3.0
7
+ Tested up to: 4.4
8
+ Stable tag: 3.7.6
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
78
 
79
  == Changelog ==
80
 
81
+
82
+ = 3.7.6 =
83
+ * Fixed several problems with the permalinks when using the slash character in the bases
84
+ * Fixed an issue with coupons: the coupons were not applied according to the minimum amount of the cart in the current currency
85
+ * Fixed one compatibility issue with the Flatsome theme
86
+ * Fixed a bug preventing the shop page link to be translated correctly to the other languages (when using WPML 3.3.1+)
87
+
88
  = 3.7.5 =
89
  * Fixed a backward compatibility with WPML versions prior 3.2 (causing fatal error)
90
  * Bug fix: in some specific cases variations were not created correctly - 'Any %name%' instead of term value
621
  Recommended update! Fixed a few bugs;
622
 
623
  = 0.9 =
624
+ * First release
wpml-woocommerce.php CHANGED
@@ -6,12 +6,12 @@
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com/
8
  Text Domain: woocommerce-multilingual
9
- Version: 3.7.5
10
  */
11
 
12
 
13
  if(defined('WCML_VERSION')) return;
14
- define('WCML_VERSION', '3.7.5');
15
  define('WCML_PLUGIN_PATH', dirname(__FILE__));
16
  define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
17
  define('WCML_LOCALE_PATH',WCML_PLUGIN_PATH.'/locale');
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com/
8
  Text Domain: woocommerce-multilingual
9
+ Version: 3.7.6
10
  */
11
 
12
 
13
  if(defined('WCML_VERSION')) return;
14
+ define('WCML_VERSION', '3.7.6');
15
  define('WCML_PLUGIN_PATH', dirname(__FILE__));
16
  define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
17
  define('WCML_LOCALE_PATH',WCML_PLUGIN_PATH.'/locale');