WooCommerce Multilingual – run WooCommerce with WPML - Version 3.4.1

Version Description

  • Bug fix: A variable product was somtimes breaking the shopping cart
  • Fixes added for translating custom fields that are textareas
Download this release

Release Info

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

Code changes from version 3.4 to 3.4.1

compatibility/wc_product_bundles.class.php CHANGED
@@ -3,12 +3,7 @@
3
  class WCML_Product_Bundles{
4
 
5
  function __construct(){
6
- add_action('init', array($this, 'init'),10);
7
- }
8
-
9
- function init(){
10
- global $sitepress;
11
- add_action('wcml_gui_additional_box',array($this,'product_bundles_box'),10,3);
12
  add_action('wcml_after_duplicate_product_post_meta',array($this,'sync_bundled_ids'),10,3);
13
  add_action('wcml_extra_titles',array($this,'product_bundles_title'),10,1);
14
  add_action('wcml_update_extra_fields',array($this,'bundle_update'),10,2);
@@ -20,71 +15,82 @@ class WCML_Product_Bundles{
20
  // Sync Bundled product '_bundle_data' with translated values when the product is duplicated
21
  function sync_bundled_ids($original_product_id, $trnsl_product_id, $data = false){
22
  global $sitepress, $wpdb;
23
- $custom_fields = get_post_custom($original_product_id);
24
  $atts = maybe_unserialize(get_post_meta($original_product_id, '_bundle_data', true));
25
- $lang = $sitepress->get_language_for_element($trnsl_product_id,'post_product');
26
- $tr_ids = array();
27
-
28
- foreach($atts as $id=>$bundle_data){
29
- $tr_id = icl_object_id($id,'product',true,$lang);
30
-
31
- $tr_bundle[$tr_id] = $bundle_data;
32
-
33
- $tr_bundle[$tr_id]['product_id'] = $tr_id;
34
-
35
- if(isset($bundle_data['product_title'])){
36
- if($bundle_data['override_title']=='yes'){
37
- $tr_bundle[$tr_id]['product_title'] = '';
38
- }else{
39
- $tr_title= get_the_title($tr_id);
40
- $tr_bundle[$tr_id]['product_title'] = $tr_title;
41
- }
42
- }
43
-
44
- if(isset($bundle_data['product_description'])){
45
- if($bundle_data['override_description']=='yes'){
46
- $tr_bundle[$tr_id]['product_description'] = '';
47
- }else{
48
- $tr_prod = get_post($tr_id);
49
- $tr_desc = $tr_prod->post_excerpt;
50
- $tr_bundle[$tr_id]['product_description'] = $tr_desc;
51
- }
52
- }
53
-
54
- if(isset($bundle_data['filter_variations']) && $bundle_data['filter_variations']=='yes'){
55
- $allowed_var = $bundle_data['allowed_variations'];
56
- foreach($allowed_var as $key=>$var_id){
57
- $tr_var_id = icl_object_id($var_id,'product_variation',true,$lang);
58
- $tr_bundle[$tr_id]['allowed_variations'][$key] = $tr_var_id;
59
- }
60
- }
61
-
62
- if(isset($bundle_data['bundle_defaults']) && !empty($bundle_data['bundle_defaults'])){
63
- foreach($bundle_data['bundle_defaults'] as $tax=>$term_slug){
64
- $term = get_term_by('slug',$term_slug, $tax);
65
- if($term!=false){
66
- // Global Attribute
67
- $tr_def_id = icl_object_id($term->term_id,$tax,true,$lang);
68
- $tr_term = get_term( $tr_def_id, $tax );
69
- $tr_bundle[$tr_id]['bundle_defaults'][$tax] = $tr_term->slug;
70
- }else{
71
- // Custom Attribute
72
- $args = array( 'post_type' => 'product_variation', 'meta_key' => 'attribute_'.$tax, 'meta_value' => $term_slug, 'meta_compare' => '=');
73
- $variationloop = new WP_Query( $args );
74
- while ( $variationloop->have_posts() ) : $variationloop->the_post();
75
- $tr_var_id = icl_object_id(get_the_ID(),'product_variation',true,$lang);
76
- $tr_meta = get_post_meta($tr_var_id, 'attribute_'.$tax , true);
77
- $tr_bundle[$tr_id]['bundle_defaults'][$tax] = $tr_meta;
78
- endwhile;
79
- }
80
-
81
- }
82
- }
83
-
84
-
 
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
-
87
- update_post_meta($trnsl_product_id,'_bundle_data',$tr_bundle);
88
  }
89
 
90
  // Update Bundled products title and descritpion after saving the translation
3
  class WCML_Product_Bundles{
4
 
5
  function __construct(){
6
+ add_action('wcml_gui_additional_box',array($this,'product_bundles_box'),10,3);
 
 
 
 
 
7
  add_action('wcml_after_duplicate_product_post_meta',array($this,'sync_bundled_ids'),10,3);
8
  add_action('wcml_extra_titles',array($this,'product_bundles_title'),10,1);
9
  add_action('wcml_update_extra_fields',array($this,'bundle_update'),10,2);
15
  // Sync Bundled product '_bundle_data' with translated values when the product is duplicated
16
  function sync_bundled_ids($original_product_id, $trnsl_product_id, $data = false){
17
  global $sitepress, $wpdb;
18
+
19
  $atts = maybe_unserialize(get_post_meta($original_product_id, '_bundle_data', true));
20
+
21
+ if( $atts ){
22
+ $lang = $sitepress->get_language_for_element($trnsl_product_id,'post_product');
23
+ $tr_ids = array();
24
+ $i = 2;
25
+ foreach($atts as $id=>$bundle_data){
26
+ $tr_id = icl_object_id($id,get_post_type($id),true,$lang);
27
+
28
+ if(isset($tr_bundle[$tr_id])){
29
+ $bundle_key = $tr_id.'_'.$i;
30
+ $i++;
31
+ }else{
32
+ $bundle_key = $tr_id;
33
+ }
34
+
35
+ $tr_bundle[$bundle_key] = $bundle_data;
36
+
37
+ $tr_bundle[$bundle_key]['product_id'] = $tr_id;
38
+
39
+ if(isset($bundle_data['product_title'])){
40
+ if($bundle_data['override_title']=='yes'){
41
+ $tr_bundle[$bundle_key]['product_title'] = '';
42
+ }else{
43
+ $tr_title= get_the_title($tr_id);
44
+ $tr_bundle[$bundle_key]['product_title'] = $tr_title;
45
+ }
46
+ }
47
+
48
+ if(isset($bundle_data['product_description'])){
49
+ if($bundle_data['override_description']=='yes'){
50
+ $tr_bundle[$bundle_key]['product_description'] = '';
51
+ }else{
52
+ $tr_prod = get_post($tr_id);
53
+ $tr_desc = $tr_prod->post_excerpt;
54
+ $tr_bundle[$bundle_key]['product_description'] = $tr_desc;
55
+ }
56
+ }
57
+
58
+ if(isset($bundle_data['filter_variations']) && $bundle_data['filter_variations']=='yes'){
59
+ $allowed_var = $bundle_data['allowed_variations'];
60
+ foreach($allowed_var as $key=>$var_id){
61
+ $tr_var_id = icl_object_id($var_id,get_post_type($var_id),true,$lang);
62
+ $tr_bundle[$bundle_key]['allowed_variations'][$key] = $tr_var_id;
63
+ }
64
+ }
65
+
66
+ if(isset($bundle_data['bundle_defaults']) && !empty($bundle_data['bundle_defaults'])){
67
+ foreach($bundle_data['bundle_defaults'] as $tax=>$term_slug){
68
+ $term = get_term_by('slug',$term_slug, $tax);
69
+ if($term!=false){
70
+ // Global Attribute
71
+ $tr_def_id = icl_object_id($term->term_id,$tax,true,$lang);
72
+ $tr_term = get_term( $tr_def_id, $tax );
73
+ $tr_bundle[$bundle_key]['bundle_defaults'][$tax] = $tr_term->slug;
74
+ }else{
75
+ // Custom Attribute
76
+ $args = array( 'post_type' => 'product_variation', 'meta_key' => 'attribute_'.$tax, 'meta_value' => $term_slug, 'meta_compare' => '=');
77
+ $variationloop = new WP_Query( $args );
78
+ while ( $variationloop->have_posts() ) : $variationloop->the_post();
79
+ $tr_var_id = icl_object_id(get_the_ID(),'product_variation',true,$lang);
80
+ $tr_meta = get_post_meta($tr_var_id, 'attribute_'.$tax , true);
81
+ $tr_bundle[$bundle_key]['bundle_defaults'][$tax] = $tr_meta;
82
+ endwhile;
83
+ }
84
+
85
+ }
86
+ }
87
+
88
+
89
+ }
90
+
91
+ update_post_meta($trnsl_product_id,'_bundle_data',$tr_bundle);
92
  }
93
+
 
94
  }
95
 
96
  // Update Bundled products title and descritpion after saving the translation
compatibility/wc_variation_swatches_photos.class.php CHANGED
@@ -3,10 +3,6 @@
3
  class WCML_Variation_Swatches_and_Photos{
4
 
5
  function __construct(){
6
- add_action('init', array($this, 'init'),9);
7
- }
8
-
9
- function init(){
10
  add_action('wcml_after_duplicate_product_post_meta',array($this,'sync_variation_swatches_and_photos'),10,3);
11
  }
12
 
3
  class WCML_Variation_Swatches_and_Photos{
4
 
5
  function __construct(){
 
 
 
 
6
  add_action('wcml_after_duplicate_product_post_meta',array($this,'sync_variation_swatches_and_photos'),10,3);
7
  }
8
 
inc/endpoints.class.php CHANGED
@@ -79,9 +79,11 @@ class WCML_Endpoints{
79
  }
80
 
81
  function endpoint_permalink_filter( $p, $pid ){
82
- global $wp,$sitepress,$post;
 
 
 
83
 
84
- if( isset($post->ID) && !is_admin() && version_compare( WOOCOMMERCE_VERSION, '2.2', '>=' )){
85
  $current_lang = $sitepress->get_current_language();
86
  $page_lang = $sitepress->get_language_for_element( $post->ID, 'post_page');
87
  if( $current_lang != $page_lang && icl_object_id( $pid, 'page', false, $page_lang ) == $post->ID ){
79
  }
80
 
81
  function endpoint_permalink_filter( $p, $pid ){
82
+ global $post;
83
+
84
+ if( isset($post->ID) && !is_admin() && version_compare( WOOCOMMERCE_VERSION, '2.2', '>=' ) && defined( 'ICL_SITEPRESS_VERSION' ) && !ICL_PLUGIN_INACTIVE ){
85
+ global $wp,$sitepress;
86
 
 
87
  $current_lang = $sitepress->get_current_language();
88
  $page_lang = $sitepress->get_language_for_element( $post->ID, 'post_page');
89
  if( $current_lang != $page_lang && icl_object_id( $pid, 'page', false, $page_lang ) == $post->ID ){
inc/terms.class.php CHANGED
@@ -26,7 +26,6 @@ class WCML_Terms{
26
  add_filter('term_link', array($this, 'translate_category_base'), 0, 3); // high priority
27
  //add_filter('term_link', array($this, 'translate_brand_link'), 10, 3);
28
 
29
- add_filter('get_term', array($this, 'clean_term'), 14, 2);
30
  add_filter('wp_get_object_terms', array($sitepress, 'get_terms_filter'));
31
 
32
  add_action('icl_save_term_translation', array($this,'save_wc_term_meta'), 100,4);
@@ -54,8 +53,6 @@ class WCML_Terms{
54
  add_filter('get_terms',array($this,'filter_coupons_terms'),10,3);
55
  add_filter('get_terms',array($this,'filter_shipping_classes_terms'),10,3);
56
 
57
- add_filter('woocommerce_attribute',array($this, 'hide_language_suffix'));
58
-
59
  }
60
 
61
  function admin_menu_setup(){
@@ -381,13 +378,7 @@ class WCML_Terms{
381
  return $url;
382
  }
383
  */
384
-
385
- function clean_term($terms) {
386
- global $sitepress;
387
- $terms->name = $sitepress->the_category_name_filter($terms->name);
388
- return $terms;
389
- }
390
-
391
  function show_term_translation_screen_notices(){
392
  global $sitepress, $wpdb;
393
  $taxonomies = array_keys(get_taxonomies(array('object_type'=>array('product')),'objects'));
@@ -889,10 +880,10 @@ class WCML_Terms{
889
  }
890
 
891
  function shipping_terms($terms, $post_id, $taxonomy){
892
- if(!is_admin() && get_post_type($post_id) == 'product' && $taxonomy == 'product_shipping_class'){
893
  global $sitepress;
894
  remove_filter('get_the_terms',array($this,'shipping_terms'), 10, 3);
895
- $terms = get_the_terms(icl_object_id($post_id,'product',true,$sitepress->get_default_language()),'product_shipping_class');
896
  add_filter('get_the_terms',array($this,'shipping_terms'), 10, 3);
897
  return $terms;
898
  }
@@ -943,17 +934,5 @@ class WCML_Terms{
943
  }
944
 
945
  }
946
-
947
- function hide_language_suffix($terms_string){
948
- global $sitepress;
949
- $terms = explode(', ', $terms_string);
950
- if($terms){
951
- foreach($terms as $k => $term){
952
- $terms[$k] = $sitepress->the_category_name_filter($term);
953
- }
954
- $terms_string = implode(', ', $terms);
955
- }
956
- return $terms_string;
957
- }
958
 
959
  }
26
  add_filter('term_link', array($this, 'translate_category_base'), 0, 3); // high priority
27
  //add_filter('term_link', array($this, 'translate_brand_link'), 10, 3);
28
 
 
29
  add_filter('wp_get_object_terms', array($sitepress, 'get_terms_filter'));
30
 
31
  add_action('icl_save_term_translation', array($this,'save_wc_term_meta'), 100,4);
53
  add_filter('get_terms',array($this,'filter_coupons_terms'),10,3);
54
  add_filter('get_terms',array($this,'filter_shipping_classes_terms'),10,3);
55
 
 
 
56
  }
57
 
58
  function admin_menu_setup(){
378
  return $url;
379
  }
380
  */
381
+
 
 
 
 
 
 
382
  function show_term_translation_screen_notices(){
383
  global $sitepress, $wpdb;
384
  $taxonomies = array_keys(get_taxonomies(array('object_type'=>array('product')),'objects'));
880
  }
881
 
882
  function shipping_terms($terms, $post_id, $taxonomy){
883
+ if(!is_admin() && ( get_post_type($post_id) == 'product' || get_post_type($post_id) == 'product_variation' ) && $taxonomy == 'product_shipping_class'){
884
  global $sitepress;
885
  remove_filter('get_the_terms',array($this,'shipping_terms'), 10, 3);
886
+ $terms = get_the_terms(icl_object_id($post_id,get_post_type($post_id),true,$sitepress->get_default_language()),'product_shipping_class');
887
  add_filter('get_the_terms',array($this,'shipping_terms'), 10, 3);
888
  return $terms;
889
  }
934
  }
935
 
936
  }
 
 
 
 
 
 
 
 
 
 
 
 
937
 
938
  }
menu/sub/product-data.php CHANGED
@@ -212,11 +212,9 @@ $button_labels = array(
212
  <button type="button" class="button-secondary wcml_file_paths<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>><?php _e('Choose a file', 'wpml-wcml') ?></button>
213
  <?php else: ?>
214
  <?php if($default_language == $key): ?>
215
- <textarea rows="1" disabled="disabled"><?php echo $trn_contents; ?></textarea><br>
216
- <?php elseif(in_array($product_content,array('_purchase_note'))): ?>
217
- <textarea class="<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" name="<?php echo $product_content.'_'.$key; ?>" rows="2" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?> ><?php echo $trn_contents; ?></textarea>
218
  <?php else: ?>
219
- <input class="<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" type="text" name="<?php echo $product_content.'_'.$key; ?>" value="<?php echo $trn_contents; ?>" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?> /><br>
220
  <?php endif;?>
221
  <?php endif; ?>
222
  </td>
212
  <button type="button" class="button-secondary wcml_file_paths<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>><?php _e('Choose a file', 'wpml-wcml') ?></button>
213
  <?php else: ?>
214
  <?php if($default_language == $key): ?>
215
+ <textarea rows="1" disabled="disabled"><?php echo $trn_contents; ?></textarea><br>
 
 
216
  <?php else: ?>
217
+ <textarea class="<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" name="<?php echo $product_content.'_'.$key; ?>" rows="2" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?> ><?php echo $trn_contents; ?></textarea>
218
  <?php endif;?>
219
  <?php endif; ?>
220
  </td>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multili
5
  License: GPLv2
6
  Requires at least: 3.0
7
  Tested up to: 4.0
8
- Stable tag: 3.4
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
@@ -77,6 +77,10 @@ In order for the checkout and store pages to appear translated, you need to crea
77
 
78
  == Changelog ==
79
 
 
 
 
 
80
  = 3.4 =
81
  * Additional support for updating the WooCommerce translations.
82
  * Added currency switcher for the WooCommerce status widget on the WordPress admin dashboard.
5
  License: GPLv2
6
  Requires at least: 3.0
7
  Tested up to: 4.0
8
+ Stable tag: 3.4.1
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
77
 
78
  == Changelog ==
79
 
80
+ = 3.4.1 =
81
+ * Bug fix: A variable product was somtimes breaking the shopping cart
82
+ * Fixes added for translating custom fields that are textareas
83
+
84
  = 3.4 =
85
  * Additional support for updating the WooCommerce translations.
86
  * Added currency switcher for the WooCommerce status widget on the WordPress admin dashboard.
wpml-woocommerce.php CHANGED
@@ -5,12 +5,12 @@
5
  Description: Allows running fully multilingual e-Commerce sites with WooCommerce and WPML. <a href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/">Documentation</a>.
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com/
8
- Version: 3.4
9
  */
10
 
11
 
12
  if(defined('WCML_VERSION')) return;
13
- define('WCML_VERSION', '3.4');
14
  define('WCML_PLUGIN_PATH', dirname(__FILE__));
15
  define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
16
  define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);
5
  Description: Allows running fully multilingual e-Commerce sites with WooCommerce and WPML. <a href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/">Documentation</a>.
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com/
8
+ Version: 3.4.1
9
  */
10
 
11
 
12
  if(defined('WCML_VERSION')) return;
13
+ define('WCML_VERSION', '3.4.1');
14
  define('WCML_PLUGIN_PATH', dirname(__FILE__));
15
  define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
16
  define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);