WooCommerce Multilingual – run WooCommerce with WPML - Version 3.4

Version Description

  • Additional support for updating the WooCommerce translations.
  • Added currency switcher for the WooCommerce status widget on the WordPress admin dashboard.
  • Usability fixes for the translation of custom attributes in the WooCommerce native editor.
  • Added validation for the sale amount when using custom prices with multi-currency.
  • Bug fixed: Incorrect currency symbol position on edit order page.
  • Bug fixed: Incorrect currency displayed for order when editing an order in the backend.
  • Bug fixed: Coupon option 'Exclude sale items' was not being applied correctly. Sale items were not excluded.
  • Bug fixed: Currency switcher widget was not showing under the available widgets list in the backend.
  • Bug fixed: The breadcrumbs structure dropped the shop page when WooCommerce Multilingual was activated.
  • Bug fixed: Manually adding a product to an order is not taking a custom price (secondary currency) if set.
  • Bug fixed: Error when trying to add a category when All languages was selected in the admin language switcher.
Download this release

Release Info

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

Code changes from version 3.3.4 to 3.4

assets/css/wcml-prices.css CHANGED
@@ -63,6 +63,7 @@
63
  .currency_blck>label,
64
  .wcml_automaticaly_prices_block>label{
65
  font-weight: bold;
 
66
  }
67
 
68
  .wcml_schedule_manually_block_hide,
@@ -97,3 +98,13 @@
97
  .options_group.show_if_downloadable{
98
  clear: both;
99
  }
 
 
 
 
 
 
 
 
 
 
63
  .currency_blck>label,
64
  .wcml_automaticaly_prices_block>label{
65
  font-weight: bold;
66
+ margin-left: 0;
67
  }
68
 
69
  .wcml_schedule_manually_block_hide,
98
  .options_group.show_if_downloadable{
99
  clear: both;
100
  }
101
+ .wcml_price_error{
102
+ display: none;
103
+ background: #aa0000;
104
+ color: #fff;
105
+ font-size: 12px;
106
+ font-weight: bold;
107
+ margin-left: 5px;
108
+ float: left;
109
+ padding: 1px 5px;
110
+ }
assets/js/lock_fields.js CHANGED
@@ -7,13 +7,13 @@ jQuery(document).ready(function($){
7
  $('#'+ids[i]).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
8
  }
9
 
10
- var buttons = ['add_variation','link_all_variations','attribute_taxonomy','save_attributes','add_new_attribute','remove_row','add_attribute','select_all_attributes','select_no_attributes'];
11
  for (i = 0; i < buttons.length; i++) {
12
  $('.'+buttons[i]).attr('disabled','disabled');
13
  $('.'+buttons[i]).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show().css('float','right'));
14
  }
15
 
16
- $('.remove_variation').each(function(){
17
  $(this).attr('disabled','disabled');
18
  $(this).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show().css('float','right'));
19
  });
7
  $('#'+ids[i]).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
8
  }
9
 
10
+ var buttons = ['add_variation','link_all_variations','attribute_taxonomy','save_attributes','add_new_attribute','product_attributes .remove_row','add_attribute','select_all_attributes','select_no_attributes'];
11
  for (i = 0; i < buttons.length; i++) {
12
  $('.'+buttons[i]).attr('disabled','disabled');
13
  $('.'+buttons[i]).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show().css('float','right'));
14
  }
15
 
16
+ $('.remove_variation,.attribute_name,.woocommerce_attribute_data td textarea').each(function(){
17
  $(this).attr('disabled','disabled');
18
  $(this).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show().css('float','right'));
19
  });
assets/js/prices.js CHANGED
@@ -133,6 +133,23 @@ jQuery(document).ready(function($){
133
  }
134
  });
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  function datepick(){
137
  var date_img = '';
138
  if(typeof woocommerce_admin_meta_boxes != 'undefined'){
133
  }
134
  });
135
 
136
+
137
+ $(document).on('keyup','.wcml_sale_price', function(){
138
+ if( parseInt($(this).val()) > parseInt($(this).closest('div').find('.wcml_regular_price').val()) ){
139
+ if( $(this).closest('p').find('.wcml_price_error').size() == 0 )
140
+ $(this).after($('.wcml_price_error').clone().show());
141
+ }else{
142
+ $(this).closest('p').find('.wcml_price_error').remove();
143
+ }
144
+ });
145
+
146
+ $(document).on('change','.wcml_sale_price', function(){
147
+ if( parseInt($(this).val()) > parseInt($(this).closest('div').find('.wcml_regular_price').val()) ){
148
+ $(this).val($(this).closest('div').find('.wcml_regular_price').val());
149
+ $(this).closest('p').find('.wcml_price_error').remove();
150
+ }
151
+ });
152
+
153
  function datepick(){
154
  var date_img = '';
155
  if(typeof woocommerce_admin_meta_boxes != 'undefined'){
assets/js/scripts.js CHANGED
@@ -730,7 +730,7 @@ jQuery(document).ready(function($){
730
 
731
  }
732
 
733
- $(document).on('click', '#wcml_fix_strings_language', function(){
734
 
735
  var thisb = $(this);
736
  thisb.prop('disabled', true);
730
 
731
  }
732
 
733
+ $(document).on('click', '#wcml_fix_strings_language', function(){ // TODO: remove after WPML 3.2 release
734
 
735
  var thisb = $(this);
736
  thisb.prop('disabled', true);
inc/currency-switcher-widget.class.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WC_Currency_Switcher_Widget extends WP_Widget {
4
+
5
+ function __construct() {
6
+
7
+ parent::__construct( 'currency_sel_widget', __('Currency switcher', 'wpml-wcml'), __('Currency switcher', 'wpml-wcml'));
8
+ }
9
+
10
+ function widget($args, $instance) {
11
+
12
+ echo $args['before_widget'];
13
+
14
+ do_action('currency_switcher');
15
+
16
+ echo $args['after_widget'];
17
+ }
18
+
19
+ function form( $instance ) {
20
+
21
+ printf('<p><a href="%s">%s</a></p>','admin.php?page=wpml-wcml#currency-switcher',__('Configure options','wpml-wcml'));
22
+ return;
23
+
24
+ }
25
+ }
inc/currency-switcher.class.php CHANGED
@@ -8,8 +8,8 @@ class WCML_CurrencySwitcher{
8
 
9
  function __construct(){
10
 
11
- add_filter('init', array($this, 'init'), 5);
12
- add_action('widgets_init', array($this, 'register_widget'));
13
  }
14
 
15
  function init(){
@@ -41,32 +41,4 @@ class WCML_CurrencySwitcher{
41
  die();
42
  }
43
 
44
- function register_widget(){
45
- register_widget('WC_Currency_Switcher_Widget');
46
- }
47
-
48
- }
49
-
50
- class WC_Currency_Switcher_Widget extends WP_Widget {
51
-
52
- function __construct() {
53
-
54
- parent::__construct( 'currency_sel_widget', __('Currency switcher', 'wpml-wcml'), __('Currency switcher', 'wpml-wcml'));
55
- }
56
-
57
- function widget($args, $instance) {
58
-
59
- echo $args['before_widget'];
60
-
61
- do_action('currency_switcher');
62
-
63
- echo $args['after_widget'];
64
- }
65
-
66
- function form( $instance ) {
67
-
68
- printf('<p><a href="%s">%s</a></p>','admin.php?page=wpml-wcml#currency-switcher',__('Configure options','wpml-wcml'));
69
- return;
70
-
71
- }
72
  }
8
 
9
  function __construct(){
10
 
11
+ add_action('init', array($this, 'init'), 5);
12
+
13
  }
14
 
15
  function init(){
41
  die();
42
  }
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
inc/dependencies.class.php CHANGED
@@ -9,7 +9,7 @@ class WCML_Dependencies{
9
  function __construct(){
10
 
11
  if(is_admin()){
12
- add_action('wp_ajax_wcml_fix_strings_language', array($this, 'fix_strings_language'));
13
 
14
  add_action('init', array($this, 'check_wpml_config'), 100);
15
  }
9
  function __construct(){
10
 
11
  if(is_admin()){
12
+ add_action('wp_ajax_wcml_fix_strings_language', array($this, 'fix_strings_language')); // TODO: remove after WPML 3.2 release
13
 
14
  add_action('init', array($this, 'check_wpml_config'), 100);
15
  }
inc/emails.class.php CHANGED
@@ -97,22 +97,31 @@ class WCML_Emails{
97
 
98
  function comments_language(){
99
  global $sitepress_settings;
100
- $this->change_email_language($sitepress_settings['st']['strings_language']);
 
 
 
 
 
 
 
 
 
101
  }
102
 
103
  function email_heading_completed($order_id){
104
- global $woocommerce,$wpdb,$sitepress_settings;
105
  if(class_exists('WC_Email_Customer_Completed_Order')){
106
- $heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'],'[woocommerce_customer_completed_order_settings]heading'));
107
  if($heading)
108
  $woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->heading = icl_t($heading[0]->context,'[woocommerce_customer_completed_order_settings]heading',$heading[0]->value);
109
- $subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_completed_order_settings]subject'));
110
  if($subject)
111
  $woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->subject = icl_t($subject[0]->context,'[woocommerce_customer_completed_order_settings]subject',$subject[0]->value);
112
- $heading_downloadable = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'],'[woocommerce_customer_completed_order_settings]heading_downloadable'));
113
  if($heading_downloadable)
114
  $woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->heading_downloadable = icl_t($heading_downloadable[0]->context,'[woocommerce_customer_completed_order_settings]heading_downloadable',$heading_downloadable[0]->value);
115
- $subject_downloadable = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_completed_order_settings]subject_downloadable'));
116
  if($subject_downloadable)
117
  $woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->subject_downloadable = icl_t($subject_downloadable[0]->context,'[woocommerce_customer_completed_order_settings]subject_downloadable',$subject_downloadable[0]->value);
118
 
@@ -124,12 +133,12 @@ class WCML_Emails{
124
  }
125
 
126
  function email_heading_processing($order_id){
127
- global $woocommerce,$wpdb,$sitepress_settings;
128
  if(class_exists('WC_Email_Customer_Processing_Order')){
129
- $heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_processing_order_settings]heading'));
130
  if($heading)
131
  $woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->heading = icl_t($heading[0]->context,'[woocommerce_customer_processing_order_settings]heading',$heading[0]->value);
132
- $subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_processing_order_settings]subject'));
133
  if($subject)
134
  $woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->subject = icl_t($subject[0]->context,'[woocommerce_customer_processing_order_settings]subject',$subject[0]->value);
135
 
@@ -141,12 +150,12 @@ class WCML_Emails{
141
  }
142
 
143
  function email_heading_note($args){
144
- global $woocommerce,$wpdb,$sitepress_settings,$sitepress;
145
  if(class_exists('WC_Email_Customer_Note')){
146
- $heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_customer_note_settings]heading'));
147
  if($heading)
148
  $woocommerce->mailer()->emails['WC_Email_Customer_Note']->heading = icl_t($heading[0]->context,'[woocommerce_customer_note_settings]heading',$heading[0]->value);
149
- $subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'],'[woocommerce_customer_note_settings]subject'));
150
  if($subject)
151
  $woocommerce->mailer()->emails['WC_Email_Customer_Note']->subject = icl_t($subject[0]->context,'[woocommerce_customer_note_settings]subject',$subject[0]->value);
152
 
@@ -159,7 +168,7 @@ class WCML_Emails{
159
 
160
 
161
  function admin_email($order_id){
162
- global $woocommerce,$sitepress,$wpdb,$sitepress_settings;
163
  if(class_exists('WC_Email_New_Order')){
164
  $recipients = explode(',',$woocommerce->mailer()->emails['WC_Email_New_Order']->get_recipient());
165
  foreach($recipients as $recipient){
@@ -170,10 +179,10 @@ class WCML_Emails{
170
  $user_lang = get_post_meta($order_id, 'wpml_language', TRUE);
171
  }
172
  $this->change_email_language($user_lang);
173
- $heading = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_new_order_settings]heading'));
174
  if($heading)
175
  $woocommerce->mailer()->emails['WC_Email_New_Order']->heading = icl_t($heading[0]->context,'[woocommerce_new_order_settings]heading',$heading[0]->value);
176
- $subject = $wpdb->get_results($wpdb->prepare("SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $sitepress_settings['st']['strings_language'], '[woocommerce_new_order_settings]subject'));
177
  if($subject)
178
  $woocommerce->mailer()->emails['WC_Email_New_Order']->subject = icl_t($subject[0]->context,'[woocommerce_new_order_settings]subject',$subject[0]->value);
179
 
@@ -236,4 +245,19 @@ class WCML_Emails{
236
  return $value;
237
  }
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  }
97
 
98
  function comments_language(){
99
  global $sitepress_settings;
100
+
101
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
102
+ $context_ob = icl_st_get_context( 'plugin woocommerce' );
103
+ if($context_ob){
104
+ $this->change_email_language($context_ob->language);
105
+ }
106
+ }else{
107
+ $this->change_email_language($sitepress_settings['st']['strings_language']);
108
+ }
109
+
110
  }
111
 
112
  function email_heading_completed($order_id){
113
+ global $woocommerce;
114
  if(class_exists('WC_Email_Customer_Completed_Order')){
115
+ $heading = $this->wcml_get_email_string_info( '[woocommerce_customer_completed_order_settings]heading' );
116
  if($heading)
117
  $woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->heading = icl_t($heading[0]->context,'[woocommerce_customer_completed_order_settings]heading',$heading[0]->value);
118
+ $subject = $this->wcml_get_email_string_info( '[woocommerce_customer_completed_order_settings]subject' );
119
  if($subject)
120
  $woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->subject = icl_t($subject[0]->context,'[woocommerce_customer_completed_order_settings]subject',$subject[0]->value);
121
+ $heading_downloadable = $this->wcml_get_email_string_info( '[woocommerce_customer_completed_order_settings]heading_downloadable' );
122
  if($heading_downloadable)
123
  $woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->heading_downloadable = icl_t($heading_downloadable[0]->context,'[woocommerce_customer_completed_order_settings]heading_downloadable',$heading_downloadable[0]->value);
124
+ $subject_downloadable = $this->wcml_get_email_string_info( '[woocommerce_customer_completed_order_settings]subject_downloadable' );
125
  if($subject_downloadable)
126
  $woocommerce->mailer()->emails['WC_Email_Customer_Completed_Order']->subject_downloadable = icl_t($subject_downloadable[0]->context,'[woocommerce_customer_completed_order_settings]subject_downloadable',$subject_downloadable[0]->value);
127
 
133
  }
134
 
135
  function email_heading_processing($order_id){
136
+ global $woocommerce;
137
  if(class_exists('WC_Email_Customer_Processing_Order')){
138
+ $heading = $this->wcml_get_email_string_info( '[woocommerce_customer_processing_order_settings]heading' );
139
  if($heading)
140
  $woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->heading = icl_t($heading[0]->context,'[woocommerce_customer_processing_order_settings]heading',$heading[0]->value);
141
+ $subject = $this->wcml_get_email_string_info( '[woocommerce_customer_processing_order_settings]subject' );
142
  if($subject)
143
  $woocommerce->mailer()->emails['WC_Email_Customer_Processing_Order']->subject = icl_t($subject[0]->context,'[woocommerce_customer_processing_order_settings]subject',$subject[0]->value);
144
 
150
  }
151
 
152
  function email_heading_note($args){
153
+ global $woocommerce,$sitepress;
154
  if(class_exists('WC_Email_Customer_Note')){
155
+ $heading = $this->wcml_get_email_string_info( '[woocommerce_customer_note_settings]heading' );
156
  if($heading)
157
  $woocommerce->mailer()->emails['WC_Email_Customer_Note']->heading = icl_t($heading[0]->context,'[woocommerce_customer_note_settings]heading',$heading[0]->value);
158
+ $subject = $this->wcml_get_email_string_info( '[woocommerce_customer_note_settings]subject' );
159
  if($subject)
160
  $woocommerce->mailer()->emails['WC_Email_Customer_Note']->subject = icl_t($subject[0]->context,'[woocommerce_customer_note_settings]subject',$subject[0]->value);
161
 
168
 
169
 
170
  function admin_email($order_id){
171
+ global $woocommerce,$sitepress;
172
  if(class_exists('WC_Email_New_Order')){
173
  $recipients = explode(',',$woocommerce->mailer()->emails['WC_Email_New_Order']->get_recipient());
174
  foreach($recipients as $recipient){
179
  $user_lang = get_post_meta($order_id, 'wpml_language', TRUE);
180
  }
181
  $this->change_email_language($user_lang);
182
+ $heading = $this->wcml_get_email_string_info( '[woocommerce_new_order_settings]heading' );
183
  if($heading)
184
  $woocommerce->mailer()->emails['WC_Email_New_Order']->heading = icl_t($heading[0]->context,'[woocommerce_new_order_settings]heading',$heading[0]->value);
185
+ $subject = $this->wcml_get_email_string_info( '[woocommerce_new_order_settings]subject' );
186
  if($subject)
187
  $woocommerce->mailer()->emails['WC_Email_New_Order']->subject = icl_t($subject[0]->context,'[woocommerce_new_order_settings]subject',$subject[0]->value);
188
 
245
  return $value;
246
  }
247
 
248
+ function wcml_get_email_string_info( $name ){
249
+ global $wpdb;
250
+
251
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
252
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT st.value,cn.context FROM {$wpdb->prefix}icl_strings as st LEFT JOIN {$wpdb->prefix}icl_string_contexts as cn ON st.context_id = cn.id WHERE st.name = %s ", $name ) );
253
+ }else{
254
+ global $sitepress_settings;
255
+ $language = $sitepress_settings['st']['strings_language'];
256
+ $result = $wpdb->get_results( $wpdb->prepare( "SELECT value,context FROM {$wpdb->prefix}icl_strings WHERE language = %s AND name = %s ", $language, $name ) );
257
+ }
258
+
259
+ return $result;
260
+
261
+ }
262
+
263
  }
inc/endpoints.class.php CHANGED
@@ -16,7 +16,7 @@ class WCML_Endpoints{
16
  }
17
 
18
  function register_endpoints_translations(){
19
- if( !class_exists( 'woocommerce' ) || !defined( 'ICL_SITEPRESS_VERSION' ) || ICL_PLUGIN_INACTIVE ) return false;
20
 
21
  $wc_vars = WC()->query->query_vars;
22
 
@@ -81,7 +81,7 @@ class WCML_Endpoints{
81
  function endpoint_permalink_filter( $p, $pid ){
82
  global $wp,$sitepress,$post;
83
 
84
- if( isset($post->ID) && !is_admin() ){
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 ){
16
  }
17
 
18
  function register_endpoints_translations(){
19
+ if( !class_exists( 'woocommerce' ) || !defined( 'ICL_SITEPRESS_VERSION' ) || ICL_PLUGIN_INACTIVE || version_compare( WOOCOMMERCE_VERSION, '2.2', '<' ) ) return false;
20
 
21
  $wc_vars = WC()->query->query_vars;
22
 
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 ){
inc/multi-currency-support.class.php CHANGED
@@ -512,6 +512,8 @@ class WCML_Multi_Currency_Support{
512
  $currency_code = $_COOKIE[ '_wcml_order_currency' ];
513
  }elseif( isset($_GET['post']) && get_post_type($_GET['post']) == 'shop_order'){
514
  $currency_code = get_post_meta( $_GET['post'], '_order_currency', true );
 
 
515
  }else{
516
  $currency_code = $this->client_currency;
517
  }
@@ -980,7 +982,7 @@ class WCML_Multi_Currency_Support{
980
  global $woocommerce, $woocommerce_wpml, $sitepress;
981
 
982
  $default_currencies = $woocommerce_wpml->settings['default_currencies'];
983
- $current_language = $sitepress->get_current_language();
984
  $active_languages = $sitepress->get_active_languages();
985
 
986
  if(isset($_POST['action']) && $_POST['action'] == 'wcml_switch_currency' && !empty($_POST['currency'])){
512
  $currency_code = $_COOKIE[ '_wcml_order_currency' ];
513
  }elseif( isset($_GET['post']) && get_post_type($_GET['post']) == 'shop_order'){
514
  $currency_code = get_post_meta( $_GET['post'], '_order_currency', true );
515
+ }elseif( isset( $_COOKIE[ '_wcml_dashboard_currency' ] ) && $pagenow == 'index.php' ){
516
+ $currency_code = $_COOKIE[ '_wcml_dashboard_currency' ];
517
  }else{
518
  $currency_code = $this->client_currency;
519
  }
982
  global $woocommerce, $woocommerce_wpml, $sitepress;
983
 
984
  $default_currencies = $woocommerce_wpml->settings['default_currencies'];
985
+ $current_language = $sitepress->get_current_language() != 'all' ? $sitepress->get_current_language() : $sitepress->get_default_language();
986
  $active_languages = $sitepress->get_active_languages();
987
 
988
  if(isset($_POST['action']) && $_POST['action'] == 'wcml_switch_currency' && !empty($_POST['currency'])){
inc/multi-currency.class.php CHANGED
@@ -31,6 +31,9 @@ class WCML_WC_MultiCurrency{
31
 
32
  add_filter('wcml_exchange_rates', array($this, 'get_exchange_rates'));
33
 
 
 
 
34
  // exchange rate GUI and logic
35
  if(is_admin()){
36
 
@@ -84,6 +87,20 @@ class WCML_WC_MultiCurrency{
84
  //custom prices for different currencies for products/variations [BACKEND]
85
  add_action('woocommerce_product_options_pricing',array($this,'woocommerce_product_options_custom_pricing'));
86
  add_action('woocommerce_product_after_variable_attributes',array($this,'woocommerce_product_after_variable_attributes_custom_pricing'),10,3);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
 
89
 
@@ -232,7 +249,7 @@ class WCML_WC_MultiCurrency{
232
  }else{
233
  $amount = 0;
234
  }
235
-
236
  if( $decimals_num ){
237
  $amount = number_format( (float)$amount, $decimals_num, $decimal_sep, $thousand_sep );
238
  }
@@ -275,7 +292,7 @@ class WCML_WC_MultiCurrency{
275
  }
276
 
277
  }
278
-
279
  if( $decimals_num ){
280
  $amount = number_format( (float)$amount, $decimals_num, $decimal_sep, $thousand_sep );
281
  }
@@ -454,32 +471,35 @@ class WCML_WC_MultiCurrency{
454
  }
455
 
456
  $current_screen = get_current_screen();
457
-
458
  remove_filter('woocommerce_currency_symbol', array($this, '_use_order_currency_symbol'));
459
- if(!empty($current_screen) && $current_screen->id == 'shop_order'){
460
-
461
- $the_order = new WC_Order( get_the_ID() );
462
  if($the_order && method_exists($the_order, 'get_order_currency')){
463
  if( !$the_order->get_order_currency() && isset( $_COOKIE[ '_wcml_order_currency' ] ) ){
464
  $currency = get_woocommerce_currency_symbol($_COOKIE[ '_wcml_order_currency' ]);
465
  }else{
466
- $currency = get_woocommerce_currency_symbol($the_order->get_order_currency());
467
  }
468
  }
469
 
470
- }elseif( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'woocommerce_add_order_item', 'woocommerce_calc_line_taxes', 'woocommerce_save_order_items' ) ) && isset( $_COOKIE[ '_wcml_order_currency' ] ) ){
471
-
472
- $currency = get_woocommerce_currency_symbol($_COOKIE[ '_wcml_order_currency' ]);
473
 
 
 
 
 
 
474
  }
475
 
476
  add_filter('woocommerce_currency_symbol', array($this, '_use_order_currency_symbol'));
477
-
478
  return $currency;
479
  }
480
 
481
  function reports_init(){
482
-
483
  if(isset($_GET['page']) && ($_GET['page'] == 'woocommerce_reports' || $_GET['page'] == 'wc-reports')){ //wc-reports - 2.1.x, woocommerce_reports 2.0.x
484
 
485
  add_filter('woocommerce_reports_get_order_report_query', array($this, 'admin_reports_query_filter'));
@@ -596,7 +616,7 @@ class WCML_WC_MultiCurrency{
596
  $query['join'] .= " LEFT JOIN {$wpdb->postmeta} AS meta_order_currency ON meta_order_currency.post_id = posts.ID ";
597
 
598
  $query['where'] .= sprintf(" AND meta_order_currency.meta_key='_order_currency' AND meta_order_currency.meta_value = '%s' ", $this->reports_currency);
599
-
600
  return $query;
601
  }
602
 
@@ -689,14 +709,14 @@ class WCML_WC_MultiCurrency{
689
  }else{
690
  if(typeof response.items !== 'undefined'){
691
  jQuery.each(response.items, function(index, value) {
692
- var item = jQuery('tr[data-order_item_id = '+index+']');
693
- item.attr('data-unit_subtotal',value.line_subtotal);
694
- item.attr('data-unit_total',value.line_total);
695
- item.find('.view .amount').html(value.display_total);
696
- item.find('.line_cost .edit .line_subtotal').val(value.line_subtotal);
697
- item.find('.line_cost .edit .line_total').val(value.line_total);
698
- });
699
- }
700
  jQuery('.wc-order-totals tr:nth-child(1) .amount').html(response.shipp);
701
  jQuery('.wc-order-totals tr:nth-child(2) .amount').html(response.disc_disp);
702
  jQuery('.wc-order-totals tr:nth-child(3) .amount').html(response.total_disp);
@@ -778,19 +798,38 @@ class WCML_WC_MultiCurrency{
778
  $line_total = wc_get_order_item_meta( $item->order_item_id, '_line_total', true );
779
  $line_tax = wc_get_order_item_meta( $item->order_item_id, '_line_tax', true );
780
 
781
- if( $_POST[ 'prev_currency' ] != 'false' ){
782
- $line_subtotal = $this->unconvert_price_amount( $line_subtotal, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
783
  $line_subtotal_tax = $this->unconvert_price_amount( $line_subtotal_tax, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep );
784
- $line_total = $this->unconvert_price_amount( $line_total, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep );
785
  $line_tax = $this->unconvert_price_amount( $line_tax, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep );
786
  }
787
 
 
 
 
 
 
 
 
788
 
789
-
790
- $line_subtotal = $this->apply_rounding_rules( $this->convert_price_amount( $line_subtotal, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] );
791
  wc_update_order_item_meta( $item->order_item_id, '_line_subtotal', $line_subtotal );
792
  wc_update_order_item_meta( $item->order_item_id, '_line_subtotal_tax', $this->convert_price_amount( $line_subtotal_tax, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ) );
793
- $line_total = $this->apply_rounding_rules( $this->convert_price_amount( $line_total, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] );
794
  wc_update_order_item_meta( $item->order_item_id, '_line_total', $line_total );
795
  wc_update_order_item_meta( $item->order_item_id, '_line_tax', $this->convert_price_amount( $line_tax, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ) );
796
 
@@ -866,16 +905,28 @@ class WCML_WC_MultiCurrency{
866
 
867
  function filter_ajax_order_item( $item, $item_id ){
868
  if( !get_post_meta( $_POST['order_id'], '_order_currency') ){
869
- $item['line_subtotal'] = $this->apply_rounding_rules( $this->convert_price_amount( $item['line_subtotal'], $this->get_cookie_order_currency() ), $this->get_cookie_order_currency() );
870
- wc_update_order_item_meta( $item_id, '_line_subtotal', $item['line_subtotal'] );
871
- $item['line_subtotal_tax'] = $this->convert_price_amount( $item['line_subtotal_tax'], $this->get_cookie_order_currency() );
872
- wc_update_order_item_meta( $item_id, '_line_subtotal_tax', $item['line_subtotal_tax'] );
873
- $item['line_total'] = $this->apply_rounding_rules( $this->convert_price_amount( $item['line_total'], $this->get_cookie_order_currency() ), $this->get_cookie_order_currency() );
874
- wc_update_order_item_meta( $item_id, '_line_total', $item['line_total'] );
875
- $item['line_tax'] = $this->convert_price_amount( $item['line_tax'], $this->get_cookie_order_currency() );
876
- wc_update_order_item_meta( $item_id, '_line_tax', $item['line_tax'] );
877
  }
878
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
879
  return $item;
880
  }
881
 
@@ -970,19 +1021,151 @@ class WCML_WC_MultiCurrency{
970
  }
971
 
972
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
973
  /* for WC 2.0.x - start */
974
  function reports_filter_by_currency_join($join){
975
  global $wpdb;
976
 
977
  $join .= " LEFT JOIN {$wpdb->postmeta} wcml_rpm ON wcml_rpm.post_id = posts.ID ";
978
-
979
  return $join;
980
  }
981
 
982
  function reports_filter_by_currency_where($where){
983
 
984
  $where .= " AND wcml_rpm.meta_key = '_order_currency' AND wcml_rpm.meta_value = '" . esc_sql($this->reports_currency) . "'";
985
-
986
  return $where;
987
  }
988
  /* for WC 2.0.x - end */
31
 
32
  add_filter('wcml_exchange_rates', array($this, 'get_exchange_rates'));
33
 
34
+ add_filter('wcml_get_client_currency', array($this, 'get_client_currency'));
35
+
36
+
37
  // exchange rate GUI and logic
38
  if(is_admin()){
39
 
87
  //custom prices for different currencies for products/variations [BACKEND]
88
  add_action('woocommerce_product_options_pricing',array($this,'woocommerce_product_options_custom_pricing'));
89
  add_action('woocommerce_product_after_variable_attributes',array($this,'woocommerce_product_after_variable_attributes_custom_pricing'),10,3);
90
+
91
+ //dashboard status screen
92
+ if(is_admin() && ( current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ) ) ){
93
+ add_action( 'wp_dashboard_setup', array( $this, 'dashboard_currency_dropdown' ) );
94
+
95
+ add_filter( 'woocommerce_dashboard_status_widget_sales_query', array( $this, 'filter_dashboard_status_widget_sales_query' ) );
96
+ add_filter( 'woocommerce_dashboard_status_widget_top_seller_query', array( $this, 'filter_dashboard_status_widget_sales_query' ) );
97
+ add_action( 'wp_ajax_wcml_dashboard_set_currency', array( $this, 'set_dashboard_currency' ) );
98
+
99
+ add_filter('woocommerce_currency_symbol', array($this, 'filter_dashboard_currency_symbol'));
100
+ //filter query to get order by status
101
+ add_filter( 'query', array( $this, 'filter_order_status_query' ) );
102
+ }
103
+
104
  }
105
 
106
 
249
  }else{
250
  $amount = 0;
251
  }
252
+
253
  if( $decimals_num ){
254
  $amount = number_format( (float)$amount, $decimals_num, $decimal_sep, $thousand_sep );
255
  }
292
  }
293
 
294
  }
295
+
296
  if( $decimals_num ){
297
  $amount = number_format( (float)$amount, $decimals_num, $decimal_sep, $thousand_sep );
298
  }
471
  }
472
 
473
  $current_screen = get_current_screen();
474
+
475
  remove_filter('woocommerce_currency_symbol', array($this, '_use_order_currency_symbol'));
476
+ if(!empty($current_screen) && $current_screen->id == 'shop_order'){
477
+
478
+ $the_order = new WC_Order( get_the_ID() );
479
  if($the_order && method_exists($the_order, 'get_order_currency')){
480
  if( !$the_order->get_order_currency() && isset( $_COOKIE[ '_wcml_order_currency' ] ) ){
481
  $currency = get_woocommerce_currency_symbol($_COOKIE[ '_wcml_order_currency' ]);
482
  }else{
483
+ $currency = get_woocommerce_currency_symbol($the_order->get_order_currency());
484
  }
485
  }
486
 
487
+ }elseif( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'woocommerce_add_order_item', 'woocommerce_calc_line_taxes', 'woocommerce_save_order_items' ) ) ){
 
 
488
 
489
+ if( get_post_meta( $_POST['order_id'], '_order_currency' ) ){
490
+ $currency = get_woocommerce_currency_symbol( get_post_meta( $_POST['order_id'], '_order_currency', true ) );
491
+ }elseif( isset( $_COOKIE[ '_wcml_order_currency' ] ) ){
492
+ $currency = get_woocommerce_currency_symbol($_COOKIE[ '_wcml_order_currency' ]);
493
+ }
494
  }
495
 
496
  add_filter('woocommerce_currency_symbol', array($this, '_use_order_currency_symbol'));
497
+
498
  return $currency;
499
  }
500
 
501
  function reports_init(){
502
+
503
  if(isset($_GET['page']) && ($_GET['page'] == 'woocommerce_reports' || $_GET['page'] == 'wc-reports')){ //wc-reports - 2.1.x, woocommerce_reports 2.0.x
504
 
505
  add_filter('woocommerce_reports_get_order_report_query', array($this, 'admin_reports_query_filter'));
616
  $query['join'] .= " LEFT JOIN {$wpdb->postmeta} AS meta_order_currency ON meta_order_currency.post_id = posts.ID ";
617
 
618
  $query['where'] .= sprintf(" AND meta_order_currency.meta_key='_order_currency' AND meta_order_currency.meta_value = '%s' ", $this->reports_currency);
619
+
620
  return $query;
621
  }
622
 
709
  }else{
710
  if(typeof response.items !== 'undefined'){
711
  jQuery.each(response.items, function(index, value) {
712
+ var item = jQuery('tr[data-order_item_id = '+index+']');
713
+ item.attr('data-unit_subtotal',value.line_subtotal);
714
+ item.attr('data-unit_total',value.line_total);
715
+ item.find('.view .amount').html(value.display_total);
716
+ item.find('.line_cost .edit .line_subtotal').val(value.line_subtotal);
717
+ item.find('.line_cost .edit .line_total').val(value.line_total);
718
+ });
719
+ }
720
  jQuery('.wc-order-totals tr:nth-child(1) .amount').html(response.shipp);
721
  jQuery('.wc-order-totals tr:nth-child(2) .amount').html(response.disc_disp);
722
  jQuery('.wc-order-totals tr:nth-child(3) .amount').html(response.total_disp);
798
  $line_total = wc_get_order_item_meta( $item->order_item_id, '_line_total', true );
799
  $line_tax = wc_get_order_item_meta( $item->order_item_id, '_line_tax', true );
800
 
801
+ $order_item_id = wc_get_order_item_meta($item->order_item_id, '_variation_id', true );
802
+
803
+ if( !$order_item_id ){
804
+ $order_item_id = wc_get_order_item_meta($item->order_item_id, '_product_id', true );
805
+ }
806
+
807
+ if( $_POST[ 'currency' ] == get_option('woocommerce_currency') ){
808
+ $custom_price = get_post_meta( $order_item_id, '_price', true );
809
+ }else{
810
+ $custom_price = get_post_meta( $order_item_id, '_price_'.$_POST[ 'currency' ], true );
811
+ }
812
+
813
+ if( $_POST[ 'prev_currency' ] != 'false' ){
814
+
815
+ if( !$custom_price ){
816
+ $line_subtotal = $this->unconvert_price_amount( $line_subtotal, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep ) ;
817
+ $line_total = $this->unconvert_price_amount( $line_total, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep );
818
+ }
819
  $line_subtotal_tax = $this->unconvert_price_amount( $line_subtotal_tax, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep );
 
820
  $line_tax = $this->unconvert_price_amount( $line_tax, $_POST[ 'prev_currency' ], $decimals_num, $decimal_sep, $thousand_sep );
821
  }
822
 
823
+ if( $custom_price ){
824
+ $line_subtotal = $custom_price;
825
+ $line_total = $custom_price;
826
+ }else{
827
+ $line_subtotal = $this->apply_rounding_rules( $this->convert_price_amount( $line_subtotal, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] );
828
+ $line_total = $this->apply_rounding_rules( $this->convert_price_amount( $line_total, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ), $_POST[ 'currency' ] );
829
+ }
830
 
 
 
831
  wc_update_order_item_meta( $item->order_item_id, '_line_subtotal', $line_subtotal );
832
  wc_update_order_item_meta( $item->order_item_id, '_line_subtotal_tax', $this->convert_price_amount( $line_subtotal_tax, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ) );
 
833
  wc_update_order_item_meta( $item->order_item_id, '_line_total', $line_total );
834
  wc_update_order_item_meta( $item->order_item_id, '_line_tax', $this->convert_price_amount( $line_tax, $_POST[ 'currency' ], $decimals_num, $decimal_sep, $thousand_sep ) );
835
 
905
 
906
  function filter_ajax_order_item( $item, $item_id ){
907
  if( !get_post_meta( $_POST['order_id'], '_order_currency') ){
908
+ $order_currency = $this->get_cookie_order_currency();
909
+ }else{
910
+ $order_currency = get_post_meta( $_POST['order_id'], '_order_currency', true);
 
 
 
 
 
911
  }
912
 
913
+ $custom_price = get_post_meta( $_POST['item_to_add'], '_price_'.$order_currency, true );
914
+
915
+ if( $custom_price ){
916
+ $item['line_subtotal'] = $custom_price;
917
+ $item['line_total'] = $custom_price;
918
+ }else{
919
+ $item['line_subtotal'] = $this->apply_rounding_rules( $this->convert_price_amount( $item['line_subtotal'], $order_currency ), $order_currency );
920
+ $item['line_total'] = $this->apply_rounding_rules( $this->convert_price_amount( $item['line_total'], $order_currency ), $order_currency );
921
+ }
922
+
923
+ wc_update_order_item_meta( $item_id, '_line_subtotal', $item['line_subtotal'] );
924
+ $item['line_subtotal_tax'] = $this->convert_price_amount( $item['line_subtotal_tax'], $order_currency );
925
+ wc_update_order_item_meta( $item_id, '_line_subtotal_tax', $item['line_subtotal_tax'] );
926
+ wc_update_order_item_meta( $item_id, '_line_total', $item['line_total'] );
927
+ $item['line_tax'] = $this->convert_price_amount( $item['line_tax'], $order_currency );
928
+ wc_update_order_item_meta( $item_id, '_line_tax', $item['line_tax'] );
929
+
930
  return $item;
931
  }
932
 
1021
  }
1022
 
1023
 
1024
+ /*
1025
+ * Filter WC dashboard status query
1026
+ *
1027
+ * @param string $query Query to filter
1028
+ *
1029
+ * @return string
1030
+ */
1031
+ function filter_dashboard_status_widget_sales_query( $query ){
1032
+ global $wpdb;
1033
+ $currency = $this->get_cookie_dashboard_currency();
1034
+ $query['where'] .= " AND posts.ID IN ( SELECT order_currency.post_id FROM {$wpdb->postmeta} AS order_currency WHERE order_currency.meta_key = '_order_currency' AND order_currency.meta_value = '{$currency}' ) ";
1035
+
1036
+ return $query;
1037
+ }
1038
+
1039
+ /*
1040
+ * Add currency drop-down on dashboard page ( WooCommerce status block )
1041
+ */
1042
+ function dashboard_currency_dropdown(){
1043
+ global $woocommerce_wpml, $sitepress;
1044
+
1045
+ $current_dashboard_currency = $this->get_cookie_dashboard_currency();
1046
+
1047
+ $wc_currencies = get_woocommerce_currencies();
1048
+ $order_currencies = $this->get_orders_currencies();
1049
+ ?>
1050
+ <select id="dropdown_dashboard_currency" style="display: none; margin : 10px; ">
1051
+
1052
+ <?php foreach($order_currencies as $currency => $count ): ?>
1053
+
1054
+ <option value="<?php echo $currency ?>" <?php echo $current_dashboard_currency == $currency ? 'selected="selected"':''; ?>><?php echo $wc_currencies[$currency]; ?></option>
1055
+
1056
+ <?php endforeach; ?>
1057
+
1058
+ </select>
1059
+ <?php
1060
+ wc_enqueue_js( "
1061
+
1062
+ jQuery(document).ready(function(){
1063
+
1064
+ var dashboard_dropdown = jQuery('#dropdown_dashboard_currency').clone();
1065
+ jQuery('#dropdown_dashboard_currency').remove();
1066
+ dashboard_dropdown.insertBefore('.sales-this-month a').show();
1067
+ jQuery('#woocommerce_dashboard_status .wc_status_list li').css('display','table');
1068
+
1069
+ });
1070
+
1071
+ jQuery(document).on('change', '#dropdown_dashboard_currency', function(){
1072
+ jQuery.ajax({
1073
+ url: ajaxurl,
1074
+ type: 'post',
1075
+ data: {action: 'wcml_dashboard_set_currency', currency: jQuery('#dropdown_dashboard_currency').val()},
1076
+ success: function(){location.reload();}
1077
+ })
1078
+ });
1079
+ ");
1080
+ }
1081
+
1082
+ /*
1083
+ * Set dashboard currency cookie
1084
+ */
1085
+ function set_dashboard_currency(){
1086
+
1087
+ setcookie('_wcml_dashboard_currency', $_POST['currency'], time() + 86400, COOKIEPATH, COOKIE_DOMAIN);
1088
+
1089
+ die();
1090
+
1091
+ }
1092
+
1093
+ /*
1094
+ * Get dashboard currency cookie
1095
+ *
1096
+ * @return string
1097
+ *
1098
+ */
1099
+ function get_cookie_dashboard_currency(){
1100
+
1101
+ if( isset( $_COOKIE [ '_wcml_dashboard_currency' ] ) ){
1102
+ $currency = $_COOKIE[ '_wcml_dashboard_currency' ];
1103
+ }else{
1104
+ $currency = get_woocommerce_currency();
1105
+ }
1106
+
1107
+ return $currency;
1108
+ }
1109
+
1110
+ /*
1111
+ * Filter currency symbol on dashboard page
1112
+ *
1113
+ * @param string $currency Currency code
1114
+ *
1115
+ * @return string
1116
+ *
1117
+ */
1118
+ function filter_dashboard_currency_symbol( $currency ){
1119
+ global $pagenow;
1120
+
1121
+ remove_filter( 'woocommerce_currency_symbol', array( $this, 'filter_dashboard_currency_symbol' ) );
1122
+ if( isset( $_COOKIE [ '_wcml_dashboard_currency' ] ) && $pagenow == 'index.php' ){
1123
+ $currency = get_woocommerce_currency_symbol( $_COOKIE [ '_wcml_dashboard_currency' ] );
1124
+ }
1125
+ add_filter( 'woocommerce_currency_symbol', array( $this, 'filter_dashboard_currency_symbol' ) );
1126
+
1127
+ return $currency;
1128
+ }
1129
+
1130
+
1131
+ /*
1132
+ * Filter status query
1133
+ *
1134
+ * @param string $query
1135
+ *
1136
+ * @return string
1137
+ *
1138
+ */
1139
+ function filter_order_status_query( $query ){
1140
+ global $pagenow,$wpdb;
1141
+
1142
+ if( $pagenow == 'index.php' ){
1143
+ $sql = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = 'shop_order' GROUP BY post_status";
1144
+
1145
+ if( $query == $sql){
1146
+
1147
+ $currency = $this->get_cookie_dashboard_currency();
1148
+ $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = 'shop_order' AND ID IN ( SELECT order_currency.post_id FROM {$wpdb->postmeta} AS order_currency WHERE order_currency.meta_key = '_order_currency' AND order_currency.meta_value = '{$currency}' ) GROUP BY post_status";
1149
+
1150
+ }
1151
+ }
1152
+
1153
+ return $query;
1154
+ }
1155
+
1156
  /* for WC 2.0.x - start */
1157
  function reports_filter_by_currency_join($join){
1158
  global $wpdb;
1159
 
1160
  $join .= " LEFT JOIN {$wpdb->postmeta} wcml_rpm ON wcml_rpm.post_id = posts.ID ";
1161
+
1162
  return $join;
1163
  }
1164
 
1165
  function reports_filter_by_currency_where($where){
1166
 
1167
  $where .= " AND wcml_rpm.meta_key = '_order_currency' AND wcml_rpm.meta_value = '" . esc_sql($this->reports_currency) . "'";
1168
+
1169
  return $where;
1170
  }
1171
  /* for WC 2.0.x - end */
inc/orders.class.php CHANGED
@@ -34,16 +34,21 @@ class WCML_Orders{
34
  if(in_array($text,$this->standart_order_notes)){
35
  global $sitepress_settings,$wpdb;
36
 
37
- if($sitepress_settings['admin_default_language'] == $sitepress_settings['st']['strings_language']){
38
- return $text;
 
 
 
 
39
  }
40
 
41
- $string_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}icl_strings WHERE language = %s AND value = %s ", $sitepress_settings['st']['strings_language'], $text));
42
- if($string_id){
43
  $string = $wpdb->get_var($wpdb->prepare("SELECT value FROM {$wpdb->prefix}icl_string_translations WHERE string_id = %s and language = %s", $string_id, $sitepress_settings['admin_default_language']));
44
  if($string){
45
  $translations = $string;
46
  }
 
 
47
  }
48
  }
49
 
@@ -58,7 +63,13 @@ class WCML_Orders{
58
  $user_language = get_user_meta( $current_user->data->ID, 'icl_admin_language', true );
59
 
60
  foreach($comments as $key=>$comment){
61
- $comment_string_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}icl_strings WHERE language = %s AND value = %s ", $sitepress_settings['st']['strings_language'], $comment->comment_content));
 
 
 
 
 
 
62
  if($comment_string_id){
63
  $comment_string = $wpdb->get_var($wpdb->prepare("SELECT value FROM {$wpdb->prefix}icl_string_translations WHERE string_id = %s and language = %s", $comment_string_id, $user_language));
64
  if($comment_string){
34
  if(in_array($text,$this->standart_order_notes)){
35
  global $sitepress_settings,$wpdb;
36
 
37
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
38
+ $string_id = $wpdb->get_var($wpdb->prepare("SELECT st.id FROM {$wpdb->prefix}icl_strings as st LEFT JOIN {$wpdb->prefix}icl_string_contexts as cn ON st.context_id = cn.id WHERE cn.context = %s AND st.value = %s ", $domain, $text ));
39
+ $language = icl_st_get_string_language( $string_id );
40
+ }else{
41
+ $string_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}icl_strings WHERE language = %s AND value = %s ", $sitepress_settings['st']['strings_language'], $text));
42
+ $language = $sitepress_settings['st']['strings_language'];
43
  }
44
 
45
+ if( $string_id && $sitepress_settings['admin_default_language'] != $language ){
 
46
  $string = $wpdb->get_var($wpdb->prepare("SELECT value FROM {$wpdb->prefix}icl_string_translations WHERE string_id = %s and language = %s", $string_id, $sitepress_settings['admin_default_language']));
47
  if($string){
48
  $translations = $string;
49
  }
50
+ }else{
51
+ return $text;
52
  }
53
  }
54
 
63
  $user_language = get_user_meta( $current_user->data->ID, 'icl_admin_language', true );
64
 
65
  foreach($comments as $key=>$comment){
66
+
67
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
68
+ $comment_string_id = $wpdb->get_var($wpdb->prepare("SELECT st.id FROM {$wpdb->prefix}icl_strings as st LEFT JOIN {$wpdb->prefix}icl_string_contexts as cn ON st.context_id = cn.id WHERE st.value = %s ", $comment->comment_content));
69
+ }else{
70
+ $comment_string_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}icl_strings WHERE language = %s AND value = %s ", $sitepress_settings['st']['strings_language'], $comment->comment_content));
71
+ }
72
+
73
  if($comment_string_id){
74
  $comment_string = $wpdb->get_var($wpdb->prepare("SELECT value FROM {$wpdb->prefix}icl_string_translations WHERE string_id = %s and language = %s", $comment_string_id, $user_language));
75
  if($comment_string){
inc/products.class.php CHANGED
@@ -627,9 +627,19 @@ class WCML_Products{
627
  update_post_meta($tr_product_id,'_product_attributes',$orig_product_attrs);
628
 
629
  $this->sync_default_product_attr($original_product_id, $tr_product_id, $lang);
 
 
630
  //sync media
 
 
631
  $this->sync_thumbnail_id($original_product_id, $tr_product_id,$lang);
 
 
 
 
632
  $this->sync_product_gallery($original_product_id);
 
 
633
 
634
  //sync taxonomies
635
  $this->sync_product_taxonomies($original_product_id,$tr_product_id,$lang);
@@ -1626,7 +1636,7 @@ class WCML_Products{
1626
  $price = stripslashes( $sale_price );
1627
  }
1628
 
1629
- if ( $date_to < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
1630
  update_post_meta( $post_id, '_price_'.$code, stripslashes($regular_price) );
1631
  $price = stripslashes( $regular_price );
1632
  update_post_meta( $post_id, '_sale_price_dates_from_'.$code, '');
@@ -2396,8 +2406,10 @@ class WCML_Products{
2396
  }
2397
 
2398
  function media_inputs(){
2399
- echo '<input name="icl_duplicate_attachments" type="hidden" value="1" />';
2400
- echo '<input name="icl_duplicate_featured_image" type="hidden" value="1" />';
 
 
2401
  }
2402
 
2403
  function icl_pro_translation_completed($tr_product_id) {
@@ -2526,9 +2538,9 @@ class WCML_Products{
2526
  if(isset($cart->cart_contents[$key]['variation_id']) && $cart->cart_contents[$key]['variation_id']){
2527
  $tr_variation_id = icl_object_id($cart_item['variation_id'],'product_variation',false,$current_language);
2528
  if(!is_null($tr_variation_id)){
2529
- $cart->cart_contents[$key]['product_id'] = $tr_product_id;
2530
- $cart->cart_contents[$key]['variation_id'] = $tr_variation_id;
2531
- $cart->cart_contents[$key]['data']->id = $tr_product_id;
2532
  $cart->cart_contents[$key]['data']->post = get_post( $tr_product_id );
2533
  if($cart_item['variation']){
2534
 
@@ -2545,8 +2557,8 @@ class WCML_Products{
2545
  }
2546
  }else{
2547
  if(!is_null($tr_product_id)){
2548
- $cart->cart_contents[$key]['product_id'] = $tr_product_id;
2549
- $cart->cart_contents[$key]['data']->id = $tr_product_id;
2550
  $cart->cart_contents[$key]['data']->post = get_post( $tr_product_id );
2551
  }
2552
  }
627
  update_post_meta($tr_product_id,'_product_attributes',$orig_product_attrs);
628
 
629
  $this->sync_default_product_attr($original_product_id, $tr_product_id, $lang);
630
+
631
+ $wpml_media_options = maybe_unserialize(get_option('_wpml_media'));
632
  //sync media
633
+ if($wpml_media_options['new_content_settings']['duplicate_featured']){
634
+ //sync feature image
635
  $this->sync_thumbnail_id($original_product_id, $tr_product_id,$lang);
636
+ }
637
+
638
+ if($wpml_media_options['new_content_settings']['duplicate_media']){
639
+ //sync product gallery
640
  $this->sync_product_gallery($original_product_id);
641
+ }
642
+
643
 
644
  //sync taxonomies
645
  $this->sync_product_taxonomies($original_product_id,$tr_product_id,$lang);
1636
  $price = stripslashes( $sale_price );
1637
  }
1638
 
1639
+ if ( $date_to && $date_to < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
1640
  update_post_meta( $post_id, '_price_'.$code, stripslashes($regular_price) );
1641
  $price = stripslashes( $regular_price );
1642
  update_post_meta( $post_id, '_sale_price_dates_from_'.$code, '');
2406
  }
2407
 
2408
  function media_inputs(){
2409
+ $wpml_media_options = maybe_unserialize(get_option('_wpml_media'));
2410
+
2411
+ echo '<input name="icl_duplicate_attachments" type="hidden" value="'.$wpml_media_options['new_content_settings']['duplicate_media'].'" />';
2412
+ echo '<input name="icl_duplicate_featured_image" type="hidden" value="'.$wpml_media_options['new_content_settings']['duplicate_featured'].'" />';
2413
  }
2414
 
2415
  function icl_pro_translation_completed($tr_product_id) {
2538
  if(isset($cart->cart_contents[$key]['variation_id']) && $cart->cart_contents[$key]['variation_id']){
2539
  $tr_variation_id = icl_object_id($cart_item['variation_id'],'product_variation',false,$current_language);
2540
  if(!is_null($tr_variation_id)){
2541
+ $cart->cart_contents[$key]['product_id'] = intval($tr_product_id);
2542
+ $cart->cart_contents[$key]['variation_id'] = intval($tr_variation_id);
2543
+ $cart->cart_contents[$key]['data']->id = intval($tr_product_id);
2544
  $cart->cart_contents[$key]['data']->post = get_post( $tr_product_id );
2545
  if($cart_item['variation']){
2546
 
2557
  }
2558
  }else{
2559
  if(!is_null($tr_product_id)){
2560
+ $cart->cart_contents[$key]['product_id'] = intval($tr_product_id);
2561
+ $cart->cart_contents[$key]['data']->id = intval($tr_product_id);
2562
  $cart->cart_contents[$key]['data']->post = get_post( $tr_product_id );
2563
  }
2564
  }
inc/store-pages.class.php CHANGED
@@ -192,7 +192,7 @@ class WCML_Store_Pages{
192
  $shop_page = get_post( woocommerce_get_page_id('shop') );
193
  // we should explode by / for children page
194
  $query_var_page = explode('/',$q->query_vars['pagename']);
195
- if ($shop_page->post_name == $query_var_page[count($query_var_page)-1]) {
196
  unset($q->query_vars['page']);
197
  unset($q->query_vars['pagename']);
198
  $q->query_vars['post_type'] = 'product';
192
  $shop_page = get_post( woocommerce_get_page_id('shop') );
193
  // we should explode by / for children page
194
  $query_var_page = explode('/',$q->query_vars['pagename']);
195
+ if (isset($shop_page->post_name) && $shop_page->post_name == $query_var_page[count($query_var_page)-1]) {
196
  unset($q->query_vars['page']);
197
  unset($q->query_vars['pagename']);
198
  $q->query_vars['post_type'] = 'product';
inc/terms.class.php CHANGED
@@ -81,8 +81,10 @@ class WCML_Terms{
81
  global $sitepress, $sitepress_settings, $woocommerce, $woocommerce_wpml;
82
 
83
  // force saving in strings language
84
- // covers the case os using the default product category and tag bases and a default language that's not English
85
- $strings_language = $sitepress_settings['st']['strings_language'];
 
 
86
  if($sitepress->get_current_language() != $strings_language && is_array( $value ) ){
87
 
88
  $permalinks = get_option( 'woocommerce_permalinks' );
@@ -117,13 +119,13 @@ class WCML_Terms{
117
  }
118
 
119
  function rewrite_rules_filter($value){
120
- global $sitepress, $sitepress_settings, $wpdb, $wp_taxonomies,$woocommerce;
121
 
122
  if(!empty($sitepress_settings['posts_slug_translation']['on'])){
123
  add_filter('option_rewrite_rules', array('WPML_Slug_Translation', 'rewrite_rules_filter'), 1, 1);
124
  }
125
 
126
- $strings_language = $sitepress_settings['st']['strings_language'];
127
 
128
  if($sitepress->get_current_language() != $strings_language){
129
 
@@ -291,7 +293,7 @@ class WCML_Terms{
291
  }
292
 
293
  function translate_category_base($termlink, $term, $taxonomy){
294
- global $sitepress_settings, $sitepress, $wp_rewrite, $wpdb, $woocommerce;
295
  static $no_recursion_flag;
296
 
297
  // handles product categories, product tags and attributes
@@ -311,7 +313,7 @@ class WCML_Terms{
311
 
312
  $no_recursion_flag = false;
313
 
314
- $strings_language = $sitepress_settings['st']['strings_language'];
315
  $term_language = $sitepress->get_element_language_details($term->term_taxonomy_id, 'tax_' . $taxonomy);
316
 
317
  if(!empty($term_language)){
@@ -329,15 +331,19 @@ class WCML_Terms{
329
 
330
  //
331
  if($term_language->language_code != $strings_language){
332
- $base_translated = $wpdb->get_var("
333
- SELECT t.value
334
  FROM {$wpdb->prefix}icl_strings s
335
  JOIN {$wpdb->prefix}icl_string_translations t ON t.string_id = s.id
336
- WHERE s.value='". esc_sql($base)."'
337
- AND s.language = '{$strings_language}'
338
- AND s.name LIKE 'Url {$string_identifier} slug:%'
339
- AND t.language = '{$term_language->language_code}'
340
- ");
 
 
 
 
341
 
342
  }else{
343
  $base_translated = $base;
81
  global $sitepress, $sitepress_settings, $woocommerce, $woocommerce_wpml;
82
 
83
  // force saving in strings language
84
+
85
+
86
+ $strings_language = $woocommerce_wpml->strings->get_wc_context_language();
87
+
88
  if($sitepress->get_current_language() != $strings_language && is_array( $value ) ){
89
 
90
  $permalinks = get_option( 'woocommerce_permalinks' );
119
  }
120
 
121
  function rewrite_rules_filter($value){
122
+ global $sitepress, $sitepress_settings, $wpdb, $wp_taxonomies,$woocommerce,$woocommerce_wpml;
123
 
124
  if(!empty($sitepress_settings['posts_slug_translation']['on'])){
125
  add_filter('option_rewrite_rules', array('WPML_Slug_Translation', 'rewrite_rules_filter'), 1, 1);
126
  }
127
 
128
+ $strings_language = $woocommerce_wpml->strings->get_wc_context_language();
129
 
130
  if($sitepress->get_current_language() != $strings_language){
131
 
293
  }
294
 
295
  function translate_category_base($termlink, $term, $taxonomy){
296
+ global $sitepress_settings, $sitepress, $wp_rewrite, $wpdb, $woocommerce,$woocommerce_wpml;
297
  static $no_recursion_flag;
298
 
299
  // handles product categories, product tags and attributes
313
 
314
  $no_recursion_flag = false;
315
 
316
+ $strings_language = $woocommerce_wpml->strings->get_wc_context_language();
317
  $term_language = $sitepress->get_element_language_details($term->term_taxonomy_id, 'tax_' . $taxonomy);
318
 
319
  if(!empty($term_language)){
331
 
332
  //
333
  if($term_language->language_code != $strings_language){
334
+
335
+ $sql = "SELECT t.value
336
  FROM {$wpdb->prefix}icl_strings s
337
  JOIN {$wpdb->prefix}icl_string_translations t ON t.string_id = s.id
338
+ WHERE s.value='". esc_sql($base)."'";
339
+
340
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '<' ) ) {
341
+ $sql .= " AND s.language = '{$strings_language}' ";
342
+ }
343
+
344
+ $sql .= " AND s.name LIKE 'Url {$string_identifier} slug:%' AND t.language = '{$term_language->language_code}'";
345
+
346
+ $base_translated = $wpdb->get_var( $sql );
347
 
348
  }else{
349
  $base_translated = $base;
inc/wc-strings.class.php CHANGED
@@ -44,8 +44,9 @@ class WCML_WC_Strings{
44
 
45
  add_filter('woocommerce_rate_label',array($this,'translate_woocommerce_rate_label'));
46
 
 
47
 
48
-
49
  }
50
 
51
  function translated_attribute_label($label, $name){
@@ -53,17 +54,24 @@ class WCML_WC_Strings{
53
 
54
  if(is_admin() && !wpml_is_ajax()){
55
  global $wpdb,$sitepress_settings;
56
- if($sitepress_settings['admin_default_language'] == $sitepress_settings['st']['strings_language']){
57
- return $label;
 
 
 
58
  }else{
59
- $string_id = icl_get_string_id('taxonomy singular name: '.$label,'WordPress');
60
- if($string_id){
61
- $string = $wpdb->get_var($wpdb->prepare("SELECT value FROM {$wpdb->prefix}icl_string_translations WHERE string_id = %s and language = %s", $string_id, $sitepress_settings['admin_default_language']));
62
- if($string){
63
- return $string;
64
- }
 
65
  }
 
 
66
  }
 
67
  }
68
  $name = sanitize_title($name);
69
  $lang = $sitepress->get_current_language();
@@ -107,10 +115,12 @@ class WCML_WC_Strings{
107
 
108
  function translate_query_var_for_product($public_query_vars){
109
  global $wpdb, $sitepress, $sitepress_settings;
110
-
111
- if($sitepress->get_current_language() != $sitepress_settings['st']['strings_language']){
 
 
112
  $product_permalink = $this->product_permalink_slug();
113
-
114
  $translated_slug = $this->get_translated_product_base_by_lang(false,$product_permalink);
115
 
116
  if(isset($_GET[$translated_slug])){
@@ -146,32 +156,45 @@ class WCML_WC_Strings{
146
  return $translated_slug;
147
 
148
  }
149
-
150
  // Catch the default slugs for translation
151
  function translate_default_slug($translation, $text, $context, $domain) {
152
  global $sitepress_settings, $sitepress;
153
-
154
  if ($context == 'slug' || $context == 'default-slug') {
155
  $wc_slug = get_option('woocommerce_product_slug') != false ? get_option('woocommerce_product_slug') : 'product';
156
  if(is_admin()){
157
  $admin_language = $sitepress->get_admin_language();
158
  }
159
  $current_language = $sitepress->get_current_language();
160
- if ($text == $wc_slug && $domain == 'woocommerce' && isset($sitepress_settings['st'])) {
161
- $sitepress->switch_lang($sitepress_settings['st']['strings_language']);
162
- $translation = _x($text, 'URL slug', $domain);
 
 
 
 
 
 
 
 
 
 
163
  $sitepress->switch_lang($current_language);
164
  if(is_admin()){
165
- $sitepress->set_admin_language($admin_language);
166
- }
167
- }
 
 
 
168
  if(!is_admin()){
169
  $sitepress->switch_lang($current_language);
170
  }
171
  }
172
-
173
  return $translation;
174
-
175
  }
176
 
177
  function register_shipping_methods($available_methods){
@@ -181,7 +204,7 @@ class WCML_WC_Strings{
181
 
182
  return $available_methods;
183
  }
184
-
185
  function translate_tax_rates($rates){
186
  if (!empty($rates)) {
187
  foreach ($rates as &$rate) {
@@ -189,23 +212,23 @@ class WCML_WC_Strings{
189
  }
190
  }
191
 
192
- return $rates;
193
  }
194
-
195
  function translate_gateway_title($title, $gateway_title) {
196
  if (function_exists('icl_translate')) {
197
  $title = icl_translate('woocommerce', $gateway_title .'_gateway_title', $title);
198
  }
199
  return $title;
200
  }
201
-
202
  function translate_gateway_description($description, $gateway_title) {
203
  if (function_exists('icl_translate')) {
204
  $description = icl_translate('woocommerce', $gateway_title .'_gateway_description', $description);
205
  }
206
  return $description;
207
- }
208
-
209
  function translate_bacs_instructions(){
210
  $this->translate_payment_instructions('bacs');
211
  }
@@ -232,42 +255,44 @@ class WCML_WC_Strings{
232
 
233
  function register_tax_label($label){
234
  global $sitepress;
235
-
236
  if(function_exists('icl_translate')){
237
  $label = icl_translate('woocommerce', 'VAT_tax_label', $label);
238
  }
239
-
240
  return $label;
241
  }
242
-
243
  function show_custom_url_base_language_requirement(){
244
  global $sitepress_settings, $sitepress;
245
-
246
  echo '<div id="wpml_wcml_custom_base_req" style="display:none"><br /><i>';
247
- $strings_language = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
248
- echo sprintf(__('Please enter string in %s (the strings language)', 'wpml-wcml'), '<strong>' . $strings_language['display_name'] . '</strong>');
 
 
249
  echo '</i></div>';
250
  ?>
251
  <script>
252
  if(jQuery('#woocommerce_permalink_structure').length){
253
  jQuery('#woocommerce_permalink_structure').parent().append(jQuery('#wpml_wcml_custom_base_req').html());
254
- }
255
  if(jQuery('input[name="woocommerce_product_category_slug"]').length){
256
  jQuery('input[name="woocommerce_product_category_slug"]').parent().append('<br><i><?php _e('Please use a different product category base than "category"', 'wpml-wcml') ?></i>');
257
  }
258
  </script>
259
  <?php
260
-
261
  }
262
-
263
  function show_attribute_label_language_warning(){
264
  global $sitepress_settings, $sitepress;
265
-
266
- if($sitepress_settings['st']['strings_language'] != $sitepress->get_default_language()){
267
  $default_language = $sitepress->get_language_details($sitepress->get_default_language());
268
  $strings_language = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
269
  echo '<div id="wpml_wcml_attr_language" style="display:none"><div class="icl_cyan_box"><i>';
270
- echo sprintf(__("You need to enter attribute names in %s (even though your site's default language is %s). Then, translate it to %s and the rest of the site's languages using in the %sWooCommerce Multlingual admin%s.", 'wpml-wcml'),
271
  $strings_language['display_name'],
272
  $default_language['display_name'], $default_language['display_name'],
273
  '<strong><a href="' . admin_url('admin.php?page=wpml-wcml') . '">', '</a></strong>');
@@ -276,29 +301,29 @@ class WCML_WC_Strings{
276
  <script>
277
  if(jQuery('#attribute_label').length){
278
  jQuery('#attribute_label').parent().prepend(jQuery('#wpml_wcml_attr_language').html());
279
- }
280
  </script>
281
  <?php
282
-
283
  }
284
-
285
  }
286
-
287
-
288
  function translate_woocommerce_rate_label($label){
289
  if (function_exists('icl_translate')) {
290
  $label = icl_translate('woocommerce taxes', $label , $label);
291
  }
292
  return $label;
293
  }
294
-
295
  function category_base_in_strings_language($text, $original_value, $context){
296
  if($context == 'slug' && ($original_value == 'product-category' || $original_value == 'product-tag')){
297
  $text = $original_value;
298
  }
299
  return $text;
300
  }
301
-
302
  function encode_shop_slug($location, $status){
303
  if(get_post_type(get_query_var('p')) == 'product'){
304
  global $sitepress;
@@ -309,7 +334,7 @@ class WCML_WC_Strings{
309
  }
310
  return $location;
311
  }
312
-
313
 
314
  function get_missed_product_slag_translations_languages(){
315
  global $sitepress,$wpdb,$sitepress_settings;
@@ -319,8 +344,21 @@ class WCML_WC_Strings{
319
 
320
  $slug_translation_languages = $wpdb->get_col($wpdb->prepare("SELECT tr.language FROM {$wpdb->prefix}icl_strings AS s LEFT JOIN {$wpdb->prefix}icl_string_translations AS tr ON s.id = tr.string_id WHERE s.name = %s AND s.value = %s AND tr.status = %s", 'URL slug: ' . $slug, $slug, ICL_STRING_TRANSLATION_COMPLETE));
321
  $miss_slug_lang = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  foreach( $sitepress->get_active_languages() as $lang_info ){
323
- if( !in_array( $lang_info['code'], $slug_translation_languages ) && $lang_info['code'] != $sitepress_settings['st']['strings_language'] ){
324
  $miss_slug_lang[] = ucfirst($lang_info['display_name']);
325
  }
326
  }
@@ -335,4 +373,67 @@ class WCML_WC_Strings{
335
 
336
  return $slug;
337
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  }
44
 
45
  add_filter('woocommerce_rate_label',array($this,'translate_woocommerce_rate_label'));
46
 
47
+ add_action( 'woocommerce_before_template_part', array( $this, 'woocommerce_before_template_part' ), 10, 4 );
48
 
49
+ add_action( 'woocommerce_product_options_attributes', array ( $this, 'notice_after_woocommerce_product_options_attributes' ) );
50
  }
51
 
52
  function translated_attribute_label($label, $name){
54
 
55
  if(is_admin() && !wpml_is_ajax()){
56
  global $wpdb,$sitepress_settings;
57
+
58
+ $string_id = icl_get_string_id('taxonomy singular name: '.$label,'WordPress');
59
+
60
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
61
+ $strings_language = icl_st_get_string_language( $string_id );
62
  }else{
63
+ $strings_language = $sitepress_settings['st']['strings_language'];
64
+ }
65
+
66
+ if($string_id && $sitepress_settings['admin_default_language'] != $strings_language){
67
+ $string = $wpdb->get_var($wpdb->prepare("SELECT value FROM {$wpdb->prefix}icl_string_translations WHERE string_id = %s and language = %s", $string_id, $sitepress_settings['admin_default_language']));
68
+ if($string){
69
+ return $string;
70
  }
71
+ }else{
72
+ return $label;
73
  }
74
+
75
  }
76
  $name = sanitize_title($name);
77
  $lang = $sitepress->get_current_language();
115
 
116
  function translate_query_var_for_product($public_query_vars){
117
  global $wpdb, $sitepress, $sitepress_settings;
118
+
119
+ $strings_language = $this->get_wc_context_language();
120
+
121
+ if($sitepress->get_current_language() != $strings_language){
122
  $product_permalink = $this->product_permalink_slug();
123
+
124
  $translated_slug = $this->get_translated_product_base_by_lang(false,$product_permalink);
125
 
126
  if(isset($_GET[$translated_slug])){
156
  return $translated_slug;
157
 
158
  }
159
+
160
  // Catch the default slugs for translation
161
  function translate_default_slug($translation, $text, $context, $domain) {
162
  global $sitepress_settings, $sitepress;
163
+
164
  if ($context == 'slug' || $context == 'default-slug') {
165
  $wc_slug = get_option('woocommerce_product_slug') != false ? get_option('woocommerce_product_slug') : 'product';
166
  if(is_admin()){
167
  $admin_language = $sitepress->get_admin_language();
168
  }
169
  $current_language = $sitepress->get_current_language();
170
+ $strings_language = false;
171
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
172
+ $context_ob = icl_st_get_context( 'URL slugs - product' );
173
+ if($context_ob){
174
+ $strings_language = $context_ob->language;
175
+ }
176
+ }elseif(isset($sitepress_settings['st'])){
177
+ $strings_language = $sitepress_settings['st']['strings_language'];
178
+ }
179
+
180
+ if ($text == $wc_slug && $domain == 'woocommerce' && $strings_language) {
181
+ $sitepress->switch_lang($strings_language);
182
+ $translation = _x($text, 'URL slug', $domain);
183
  $sitepress->switch_lang($current_language);
184
  if(is_admin()){
185
+ $sitepress->set_admin_language($admin_language);
186
+ }
187
+ }else{
188
+ $translation = $text;
189
+ }
190
+
191
  if(!is_admin()){
192
  $sitepress->switch_lang($current_language);
193
  }
194
  }
195
+
196
  return $translation;
197
+
198
  }
199
 
200
  function register_shipping_methods($available_methods){
204
 
205
  return $available_methods;
206
  }
207
+
208
  function translate_tax_rates($rates){
209
  if (!empty($rates)) {
210
  foreach ($rates as &$rate) {
212
  }
213
  }
214
 
215
+ return $rates;
216
  }
217
+
218
  function translate_gateway_title($title, $gateway_title) {
219
  if (function_exists('icl_translate')) {
220
  $title = icl_translate('woocommerce', $gateway_title .'_gateway_title', $title);
221
  }
222
  return $title;
223
  }
224
+
225
  function translate_gateway_description($description, $gateway_title) {
226
  if (function_exists('icl_translate')) {
227
  $description = icl_translate('woocommerce', $gateway_title .'_gateway_description', $description);
228
  }
229
  return $description;
230
+ }
231
+
232
  function translate_bacs_instructions(){
233
  $this->translate_payment_instructions('bacs');
234
  }
255
 
256
  function register_tax_label($label){
257
  global $sitepress;
258
+
259
  if(function_exists('icl_translate')){
260
  $label = icl_translate('woocommerce', 'VAT_tax_label', $label);
261
  }
262
+
263
  return $label;
264
  }
265
+
266
  function show_custom_url_base_language_requirement(){
267
  global $sitepress_settings, $sitepress;
268
+
269
  echo '<div id="wpml_wcml_custom_base_req" style="display:none"><br /><i>';
270
+ if( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '<' )){
271
+ $strings_language = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
272
+ echo sprintf(__('Please enter string in %s (the strings language)', 'wpml-wcml'), '<strong>' . $strings_language['display_name'] . '</strong>');
273
+ }
274
  echo '</i></div>';
275
  ?>
276
  <script>
277
  if(jQuery('#woocommerce_permalink_structure').length){
278
  jQuery('#woocommerce_permalink_structure').parent().append(jQuery('#wpml_wcml_custom_base_req').html());
279
+ }
280
  if(jQuery('input[name="woocommerce_product_category_slug"]').length){
281
  jQuery('input[name="woocommerce_product_category_slug"]').parent().append('<br><i><?php _e('Please use a different product category base than "category"', 'wpml-wcml') ?></i>');
282
  }
283
  </script>
284
  <?php
285
+
286
  }
287
+
288
  function show_attribute_label_language_warning(){
289
  global $sitepress_settings, $sitepress;
290
+
291
+ if(defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '<' ) && $sitepress_settings['st']['strings_language'] != $sitepress->get_default_language()){
292
  $default_language = $sitepress->get_language_details($sitepress->get_default_language());
293
  $strings_language = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
294
  echo '<div id="wpml_wcml_attr_language" style="display:none"><div class="icl_cyan_box"><i>';
295
+ echo sprintf(__("You need to enter attribute names in %s (even though your site's default language is %s). Then, translate it to %s and the rest of the site's languages using in the %sWooCommerce Multlingual admin%s.", 'wpml-wcml'),
296
  $strings_language['display_name'],
297
  $default_language['display_name'], $default_language['display_name'],
298
  '<strong><a href="' . admin_url('admin.php?page=wpml-wcml') . '">', '</a></strong>');
301
  <script>
302
  if(jQuery('#attribute_label').length){
303
  jQuery('#attribute_label').parent().prepend(jQuery('#wpml_wcml_attr_language').html());
304
+ }
305
  </script>
306
  <?php
307
+
308
  }
309
+
310
  }
311
+
312
+
313
  function translate_woocommerce_rate_label($label){
314
  if (function_exists('icl_translate')) {
315
  $label = icl_translate('woocommerce taxes', $label , $label);
316
  }
317
  return $label;
318
  }
319
+
320
  function category_base_in_strings_language($text, $original_value, $context){
321
  if($context == 'slug' && ($original_value == 'product-category' || $original_value == 'product-tag')){
322
  $text = $original_value;
323
  }
324
  return $text;
325
  }
326
+
327
  function encode_shop_slug($location, $status){
328
  if(get_post_type(get_query_var('p')) == 'product'){
329
  global $sitepress;
334
  }
335
  return $location;
336
  }
337
+
338
 
339
  function get_missed_product_slag_translations_languages(){
340
  global $sitepress,$wpdb,$sitepress_settings;
344
 
345
  $slug_translation_languages = $wpdb->get_col($wpdb->prepare("SELECT tr.language FROM {$wpdb->prefix}icl_strings AS s LEFT JOIN {$wpdb->prefix}icl_string_translations AS tr ON s.id = tr.string_id WHERE s.name = %s AND s.value = %s AND tr.status = %s", 'URL slug: ' . $slug, $slug, ICL_STRING_TRANSLATION_COMPLETE));
346
  $miss_slug_lang = array();
347
+
348
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
349
+
350
+ $context_ob = icl_st_get_context( 'WordPress' );
351
+ if($context_ob){
352
+ $strings_language = $context_ob->language;
353
+ }else{
354
+ $strings_language = false;
355
+ }
356
+ }else{
357
+ $strings_language = $sitepress_settings['st']['strings_language'];
358
+ }
359
+
360
  foreach( $sitepress->get_active_languages() as $lang_info ){
361
+ if( !in_array( $lang_info['code'], $slug_translation_languages ) && $lang_info['code'] != $strings_language ){
362
  $miss_slug_lang[] = ucfirst($lang_info['display_name']);
363
  }
364
  }
373
 
374
  return $slug;
375
  }
376
+
377
+ function get_wc_context_language(){
378
+
379
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '>=' ) ) {
380
+
381
+ $context_ob = icl_st_get_context( 'plugin woocommerce' );
382
+ if($context_ob){
383
+ $context_language = $context_ob->language;
384
+ }else{
385
+ $context_language = false;
386
+ }
387
+
388
+ return $context_language;
389
+ }else{
390
+ global $sitepress_settings;
391
+
392
+ return $sitepress_settings['st']['strings_language'];
393
+ }
394
+
395
+ }
396
+
397
+
398
+ /*
399
+ * Add filter before include global/breadcrumb.php template
400
+ *
401
+ */
402
+ function woocommerce_before_template_part( $template_name, $template_path, $located, $args ){
403
+ if( $template_name == 'global/breadcrumb.php'){
404
+ add_filter('option_woocommerce_permalinks', array($this, 'filter_woocommerce_permalinks_option_breadcrumb_page' ), 11 );
405
+ }
406
+
407
+ }
408
+
409
+
410
+ /*
411
+ * Filter product base only on global/breadcrumb.php template page
412
+ *
413
+ */
414
+ function filter_woocommerce_permalinks_option_breadcrumb_page( $value ){
415
+ global $sitepress;
416
+
417
+ if(isset($value['product_base']) && !is_admin() && $sitepress->get_current_language() != $this->get_wc_context_language() ){
418
+ remove_filter('option_woocommerce_permalinks', array($this, 'filter_woocommerce_permalinks_option_breadcrumb_page'), 11);
419
+ $value['product_base'] = '/'.strtolower(urlencode($this->get_translated_product_base_by_lang()));
420
+
421
+ }
422
+
423
+ return $value;
424
+
425
+ }
426
+
427
+ /*
428
+ * Add notice message to users
429
+ */
430
+ function notice_after_woocommerce_product_options_attributes(){
431
+ global $sitepress;
432
+
433
+ if( isset( $_GET['post'] ) && $sitepress->get_default_language() != $sitepress->get_current_language() ){
434
+ $original_product_id = icl_object_id( $_GET['post'], 'product', true, $sitepress->get_default_language() );
435
+
436
+ printf( '<p>'.__('In order to edit custom attributes you need to use the <a href="%s">custom product translation editor</a>', 'wpml-wcml').'</p>', admin_url('admin.php?page=wpml-wcml&tab=products&prid='.$original_product_id ) );
437
+ }
438
+ }
439
  }
menu/sub/custom-prices.php CHANGED
@@ -76,13 +76,13 @@ $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
76
  }
77
  ?>
78
  <p>
79
- <label><?php echo __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
80
- <input type="<?php echo $wc_input_type; ?>" size="5" name="_custom_variation_regular_price<?php echo $custom_id ?>" class="wc_input_price wcml_input_price short" value="<?php echo $regular_price ?>" step="any" min="0" />
81
  </p>
82
 
83
  <p>
84
- <label><?php echo __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
85
- <input type="<?php echo $wc_input_type; ?>" size="5" name="_custom_variation_sale_price<?php echo $custom_id ?>" class="wc_input_price wcml_input_price short" value="<?php echo $sale_price ?>" step="any" min="0" />
86
  </p>
87
  <?php }else{
88
  $custom_id = '['.$currency_code.']';
@@ -99,9 +99,9 @@ $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
99
  $wc_input['type_val'] = 'price';
100
  }
101
 
102
- woocommerce_wp_text_input( array( 'id' => '_custom_regular_price'.$custom_id, 'value'=>$regular_price ,'class' => 'wc_input_price wcml_input_price short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
103
 
104
- woocommerce_wp_text_input( array( 'id' => '_custom_sale_price'.$custom_id, 'value'=>$sale_price , 'class' => 'wc_input_price wcml_input_price short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
105
  } ?>
106
  <div class="wcml_schedule">
107
  <label><?php _e('Schedule','wpml-wcml') ?></label>
@@ -126,8 +126,8 @@ $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
126
  $sale_price_dates_from = (isset($custom_prices['_sale_price_dates_from_'.$currency_code]) && $custom_prices['_sale_price_dates_from_'.$currency_code][0] != '') ? date_i18n( 'Y-m-d', $custom_prices['_sale_price_dates_from_'.$currency_code][0] ) : '';
127
  $sale_price_dates_to = (isset($custom_prices['_sale_price_dates_to_'.$currency_code]) && $custom_prices['_sale_price_dates_to_'.$currency_code][0] != '') ? date_i18n( 'Y-m-d', $custom_prices['_sale_price_dates_to_'.$currency_code][0] ) : '';
128
  ?>
129
- <input type="text" class="short custom_sale_price_dates_from" name="_custom_sale_price_dates_from<?php echo $custom_id; ?>" id="_custom_sale_price_dates_from<?php echo $custom_id; ?>" value="<?php echo esc_attr( $sale_price_dates_from ) ?>" placeholder="<?php echo _x( 'From&hellip;', 'placeholder', 'woocommerce' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
130
- <input type="text" class="short custom_sale_price_dates_to" name="_custom_sale_price_dates_to<?php echo $custom_id; ?>" id="_custom_sale_price_dates_to<?php echo $custom_id; ?>" value="<?php echo esc_attr( $sale_price_dates_to ) ?>" placeholder="<?php echo _x( 'To&hellip;', 'placeholder', 'woocommerce' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
131
  </div>
132
 
133
  </div>
@@ -165,12 +165,12 @@ $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
165
  <?php
166
  if($is_variation){ ?>
167
  <p>
168
- <label><?php echo __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
169
  <input type="number" size="5" name="_readonly_regular_price" class="wc_input_price short" value="<?php echo $regular_price ?>" step="any" min="0" readonly = "readonly" rel="<?php echo $currency['rate'] ?>" />
170
  </p>
171
 
172
  <p>
173
- <label><?php echo __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
174
  <input type="number" size="5" name="_readonly_sale_price" class="wc_input_price short" value="<?php echo $sale_price ?>" step="any" min="0" readonly = "readonly" rel="<?php echo $currency['rate'] ?>" />
175
  </p>
176
  <?php
@@ -179,15 +179,16 @@ $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
179
 
180
  $wc_input['custom_attributes'] = array( 'readonly' => 'readonly', 'rel'=> $currency['rate'] ) ;
181
 
182
- woocommerce_wp_text_input( array( 'id' => '_readonly_regular_price', 'value'=>$regular_price, 'class' => 'wc_input_price short', 'label' => __( 'Regular Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
183
 
184
- woocommerce_wp_text_input( array( 'id' => '_readonly_sale_price', 'value'=>$sale_price, 'class' => 'wc_input_price short', 'label' => __( 'Sale Price', 'woocommerce' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
185
  }
186
 
187
  } ?>
188
 
189
  </div>
190
  <?php endif; ?>
 
191
  </div>
192
  <?php if($is_variation){ ?>
193
  </td></tr>
76
  }
77
  ?>
78
  <p>
79
+ <label><?php echo __( 'Regular Price', 'wpml-wcml' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
80
+ <input type="<?php echo $wc_input_type; ?>" size="5" name="_custom_variation_regular_price<?php echo $custom_id ?>" class="wc_input_price wcml_input_price short wcml_regular_price" value="<?php echo $regular_price ?>" step="any" min="0" />
81
  </p>
82
 
83
  <p>
84
+ <label><?php echo __( 'Sale Price', 'wpml-wcml' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
85
+ <input type="<?php echo $wc_input_type; ?>" size="5" name="_custom_variation_sale_price<?php echo $custom_id ?>" class="wc_input_price wcml_input_price short wcml_sale_price" value="<?php echo $sale_price ?>" step="any" min="0" />
86
  </p>
87
  <?php }else{
88
  $custom_id = '['.$currency_code.']';
99
  $wc_input['type_val'] = 'price';
100
  }
101
 
102
+ woocommerce_wp_text_input( array( 'id' => '_custom_regular_price'.$custom_id, 'value'=>$regular_price ,'class' => 'wc_input_price wcml_input_price short wcml_regular_price', 'label' => __( 'Regular Price', 'wpml-wcml' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
103
 
104
+ woocommerce_wp_text_input( array( 'id' => '_custom_sale_price'.$custom_id, 'value'=>$sale_price , 'class' => 'wc_input_price wcml_input_price short wcml_sale_price', 'label' => __( 'Sale Price', 'wpml-wcml' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
105
  } ?>
106
  <div class="wcml_schedule">
107
  <label><?php _e('Schedule','wpml-wcml') ?></label>
126
  $sale_price_dates_from = (isset($custom_prices['_sale_price_dates_from_'.$currency_code]) && $custom_prices['_sale_price_dates_from_'.$currency_code][0] != '') ? date_i18n( 'Y-m-d', $custom_prices['_sale_price_dates_from_'.$currency_code][0] ) : '';
127
  $sale_price_dates_to = (isset($custom_prices['_sale_price_dates_to_'.$currency_code]) && $custom_prices['_sale_price_dates_to_'.$currency_code][0] != '') ? date_i18n( 'Y-m-d', $custom_prices['_sale_price_dates_to_'.$currency_code][0] ) : '';
128
  ?>
129
+ <input type="text" class="short custom_sale_price_dates_from" name="_custom_sale_price_dates_from<?php echo $custom_id; ?>" id="_custom_sale_price_dates_from<?php echo $custom_id; ?>" value="<?php echo esc_attr( $sale_price_dates_from ) ?>" placeholder="<?php echo _x( 'From&hellip;', 'placeholder', 'wpml-wcml' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
130
+ <input type="text" class="short custom_sale_price_dates_to" name="_custom_sale_price_dates_to<?php echo $custom_id; ?>" id="_custom_sale_price_dates_to<?php echo $custom_id; ?>" value="<?php echo esc_attr( $sale_price_dates_to ) ?>" placeholder="<?php echo _x( 'To&hellip;', 'placeholder', 'wpml-wcml' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
131
  </div>
132
 
133
  </div>
165
  <?php
166
  if($is_variation){ ?>
167
  <p>
168
+ <label><?php echo __( 'Regular Price', 'wpml-wcml' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
169
  <input type="number" size="5" name="_readonly_regular_price" class="wc_input_price short" value="<?php echo $regular_price ?>" step="any" min="0" readonly = "readonly" rel="<?php echo $currency['rate'] ?>" />
170
  </p>
171
 
172
  <p>
173
+ <label><?php echo __( 'Sale Price', 'wpml-wcml' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')' ?></label>
174
  <input type="number" size="5" name="_readonly_sale_price" class="wc_input_price short" value="<?php echo $sale_price ?>" step="any" min="0" readonly = "readonly" rel="<?php echo $currency['rate'] ?>" />
175
  </p>
176
  <?php
179
 
180
  $wc_input['custom_attributes'] = array( 'readonly' => 'readonly', 'rel'=> $currency['rate'] ) ;
181
 
182
+ woocommerce_wp_text_input( array( 'id' => '_readonly_regular_price', 'value'=>$regular_price, 'class' => 'wc_input_price short', 'label' => __( 'Regular Price', 'wpml-wcml' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
183
 
184
+ woocommerce_wp_text_input( array( 'id' => '_readonly_sale_price', 'value'=>$sale_price, 'class' => 'wc_input_price short', 'label' => __( 'Sale Price', 'wpml-wcml' ) . ' ('.get_woocommerce_currency_symbol($currency_code).')', $wc_input['type_name'] => $wc_input['type_val'], 'custom_attributes' => $wc_input['custom_attributes'] ) );
185
  }
186
 
187
  } ?>
188
 
189
  </div>
190
  <?php endif; ?>
191
+ <div class="wcml_price_error"><?php _e( 'Please enter in a value less than the regular price', 'wpml-wcml' ) ?></div>
192
  </div>
193
  <?php if($is_variation){ ?>
194
  </td></tr>
menu/sub/notice-translation-upgrade.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+
6
+ $notices = implode(', ', $notices);
7
+
8
+ ?>
9
+
10
+ <div id="wcml_translations_message" class="message error">
11
+ <p><?php printf( __( '<strong>WooCommerce Translation Available</strong> &#8211; Install or update your <code>%s</code> translations to version <code>%s</code>.', 'wpml-wcml' ), $notices, WC_VERSION ); ?></p>
12
+
13
+ <p>
14
+ <?php if ( is_multisite() ) : ?>
15
+ <a href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=wc-status&tab=tools&action=translation_upgrade' ), 'debug_action' ); ?>" class="button-primary"><?php _e( 'Update Translation', 'wpml-wcml' ); ?></a>
16
+ <?php else : ?>
17
+ <a href="<?php echo wp_nonce_url( add_query_arg( array( 'action' => 'do-translation-upgrade' ), admin_url( 'update-core.php' ) ), 'upgrade-translations' ); ?>" class="button-primary"><?php _e( 'Update Translation', 'wpml-wcml' ); ?></a>
18
+ <?php endif; ?>
19
+ <a href="javascript:void(0);" class="button"><?php _e( 'Hide This Message', 'wpml-wcml' ); ?></a>
20
+ </p>
21
+ </div>
22
+
23
+
24
+ <script type="text/javascript">
25
+ jQuery(document).ready(function(){
26
+ jQuery('#wcml_translations_message').on('click',function(){
27
+ jQuery.ajax({
28
+ type : "post",
29
+ url : ajaxurl,
30
+ data : {
31
+ action: "hide_wcml_translations_message",
32
+ wcml_nonce: "<?php echo wp_create_nonce('hide_wcml_translations_message'); ?>"
33
+ },
34
+ success: function(response) {
35
+ jQuery('#wcml_translations_message').remove();
36
+ }
37
+ });
38
+ });
39
+
40
+ });
41
+ </script>
menu/sub/settings.php CHANGED
@@ -43,7 +43,7 @@ $default_language = $sitepress->get_default_language();
43
  $miss_slug_lang = $woocommerce_wpml->strings->get_missed_product_slag_translations_languages();
44
  $prod_slug = $woocommerce_wpml->strings->product_permalink_slug();
45
 
46
- if($default_language != 'en' && ($sitepress_settings['st']['strings_language'] != 'en' || empty($woocommerce_wpml->settings['dismiss_non_default_language_warning'])) || !empty($woocommerce_wpml->dependencies->xml_config_errors) || !empty($miss_slug_lang) ): ?>
47
  <div class="wcml-section">
48
  <div class="wcml-section-header">
49
  <h3>
@@ -60,7 +60,7 @@ if($default_language != 'en' && ($sitepress_settings['st']['strings_language'] !
60
 
61
  <?php endif;?>
62
 
63
- <?php if($default_language != 'en'): ?>
64
 
65
  <?php if($sitepress_settings['st']['strings_language'] != 'en'): ?>
66
  <p><i class="icon-warning-sign"></i><strong><?php _e('Attention required: probable problem with URLs in different languages', 'wpml-wcml') ?></strong></p>
43
  $miss_slug_lang = $woocommerce_wpml->strings->get_missed_product_slag_translations_languages();
44
  $prod_slug = $woocommerce_wpml->strings->product_permalink_slug();
45
 
46
+ if( ( defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '<' ) && $default_language != 'en' && ( $sitepress_settings['st']['strings_language'] != 'en' || empty( $woocommerce_wpml->settings['dismiss_non_default_language_warning'] ) ) ) || !empty($woocommerce_wpml->dependencies->xml_config_errors) || !empty($miss_slug_lang) ): ?>
47
  <div class="wcml-section">
48
  <div class="wcml-section-header">
49
  <h3>
60
 
61
  <?php endif;?>
62
 
63
+ <?php if(defined( 'ICL_SITEPRESS_VERSION' ) && version_compare( ICL_SITEPRESS_VERSION, '3.2', '<' ) && $default_language != 'en'): ?>
64
 
65
  <?php if($sitepress_settings['st']['strings_language'] != 'en'): ?>
66
  <p><i class="icon-warning-sign"></i><strong><?php _e('Attention required: probable problem with URLs in different languages', 'wpml-wcml') ?></strong></p>
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.3.4
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
@@ -77,6 +77,19 @@ In order for the checkout and store pages to appear translated, you need to crea
77
 
78
  == Changelog ==
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  = 3.3.4 =
81
  * Fixed bug related to back-compatibility with WooCommerce versions < 2.2.*
82
 
@@ -111,7 +124,7 @@ In order for the checkout and store pages to appear translated, you need to crea
111
 
112
  = 3.3.1 =
113
  * Some strings were showing in the wrong language on the cart and checkout page.
114
- * Product category urls - in some cases the product category urls didn�t work on sites with the default language different than English.
115
  * Products gallery images synchronization - sometimes, when synchronizing products "gallery images" and categories, the result was not updated correctly on the Troubleshooting page
116
  * Fixed issues related to WooCOmmerce Dynamic Pricing
117
  * Supoprt for translating WooCommerce 2.1+ endpoints
@@ -130,45 +143,45 @@ In order for the checkout and store pages to appear translated, you need to crea
130
  * Dependencies update: WooCommerce Multilingual requires WPML 3.1.5
131
  * Set language information for existing products when installing WCML the first time.
132
  * Do not allow disabling all currencies for a language
133
- * Removed �clean up test content� and �send to translation� dropdown on products editor page
134
  * Message about overwritten settings in wpml-config made more explicit
135
- * Lock �Default variation� select field in product translations
136
  * After change shipping method on cart page we will see not translated strings
137
  * Fixed bug related to shipping cost calculation in multi-currency mode
138
  * With php magic quotes on, products translations with quotes have backslashes
139
- * Bug related to translation of grouped products � simple product not showing up on front end
140
- * Stock actions on the order page don�t work correct with translated products
141
  * For Orders save attributes in default language and display them on order page in admin language
142
  * Attribute Label appearing untranslated in backend order
143
  * Memory issues on the Products tab when we have a large number of products
144
- * �product-category� not translated in the default language.
145
- * �WCML_Products� does not have a method �translated_cart_item_name�
146
  * Order completed emails sent in default currency
147
  * Language suffix (e.g. @en) not hidden for product attributes on the front end
148
  * Quick edit functionality issues fixed
149
- * Fixed �Call to undefined method WC_Session_Handler::get()�
150
- * Fatal error when updating the order status to �complete�
151
  * Currency is not converted when you switch language until you refresh the page.
152
- * �Super Admin� not able to see the WCML menu
153
  * Checkout validation errors in default language instead of user language
154
- * Fixes for compatibility with Tab manager: Can�t translate �Additional Information� tab title
155
  * Bug: SEO title & meta description changed to original
156
- * Bug: 404 on �view my order� on secondary language using �language name added as a parameter�
157
  * Bug: Permalink placeholders appear translated when using default language different than English
158
  * Fixes for compatibility with Table Rate shipping: shipping classes not decoded correctly in multi-currency mode
159
- * Bug: �show all products� link on WCML products page points to the wrong page � no products
160
- * Bug fix: product page redirecting to homepage when the product post type slug was identical in different languages and �language added as a parameter� was set
161
  * Bug fixes related to File paths functionality (WooComemrce 2.1.x)
162
  * Bug: Product parents not synced between translations (grouped products)
163
  * Bug: Grouped products title incomplete
164
  * Bug: Db Error when saving translation of variable products with custom attributes
165
  * Bug: WooCommerce translated product attributes with spaces not showing
166
- * Bug: Deactivated currency still appears if you maintain the default currency for that language to �Keep�.
167
  * Bug: Incorrect shipping value on translated page
168
  * Bug: Reports for products including only products in the current language (WooCommerce 2.1.x)
169
  * Bug: WooCommerce translated product attributes with spaces not showing
170
  * Bug: Problems creating translations for shop pages when existing pages were trashed
171
- * Bug fix: Fatal error when Multi-currency is not enabled and �Table Rate Shipping� plugin is active
172
  * Fixed bug in compatibility with Tab Manager
173
  * Bug fix: Cart strings falling to default language after updating chosen shipping method
174
  * Bug fix: Reports not including selected product/category translations
@@ -208,7 +221,7 @@ In order for the checkout and store pages to appear translated, you need to crea
208
  * Fixed bug: language names not localized on products editor page
209
  * Fixed bug: Can't set "Custom post type" to translate
210
  * Fixed bug: Translation fields not visible - In certain circumstances (e.g. search) the translation fields corresponding to the translated languages were missing
211
- * Fixed alignment for �Update/Save� button in the products translation editor
212
  * Fixed bug: Default selection not copied to duplicate products
213
  * Fixed bug: Price doesn't change when change language on the cart page when set "I will manage the pricing in each currency myself"
214
  * Resolved one compatibility issue with Woosidebars
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
 
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.
83
+ * Usability fixes for the translation of custom attributes in the WooCommerce native editor.
84
+ * Added validation for the sale amount when using custom prices with multi-currency.
85
+ * Bug fixed: Incorrect currency symbol position on edit order page.
86
+ * Bug fixed: Incorrect currency displayed for order when editing an order in the backend.
87
+ * Bug fixed: Coupon option 'Exclude sale items' was not being applied correctly. Sale items were not excluded.
88
+ * Bug fixed: Currency switcher widget was not showing under the available widgets list in the backend.
89
+ * Bug fixed: The breadcrumbs structure dropped the shop page when WooCommerce Multilingual was activated.
90
+ * Bug fixed: Manually adding a product to an order is not taking a custom price (secondary currency) if set.
91
+ * Bug fixed: Error when trying to add a category when “All languages” was selected in the admin language switcher.
92
+
93
  = 3.3.4 =
94
  * Fixed bug related to back-compatibility with WooCommerce versions < 2.2.*
95
 
124
 
125
  = 3.3.1 =
126
  * Some strings were showing in the wrong language on the cart and checkout page.
127
+ * Product category urls - in some cases the product category urls didn�t work on sites with the default language different than English.
128
  * Products gallery images synchronization - sometimes, when synchronizing products "gallery images" and categories, the result was not updated correctly on the Troubleshooting page
129
  * Fixed issues related to WooCOmmerce Dynamic Pricing
130
  * Supoprt for translating WooCommerce 2.1+ endpoints
143
  * Dependencies update: WooCommerce Multilingual requires WPML 3.1.5
144
  * Set language information for existing products when installing WCML the first time.
145
  * Do not allow disabling all currencies for a language
146
+ * Removed �clean up test content� and �send to translation� dropdown on products editor page
147
  * Message about overwritten settings in wpml-config made more explicit
148
+ * Lock �Default variation� select field in product translations
149
  * After change shipping method on cart page we will see not translated strings
150
  * Fixed bug related to shipping cost calculation in multi-currency mode
151
  * With php magic quotes on, products translations with quotes have backslashes
152
+ * Bug related to translation of grouped products � simple product not showing up on front end
153
+ * Stock actions on the order page don�t work correct with translated products
154
  * For Orders save attributes in default language and display them on order page in admin language
155
  * Attribute Label appearing untranslated in backend order
156
  * Memory issues on the Products tab when we have a large number of products
157
+ * �product-category� not translated in the default language.
158
+ * �WCML_Products� does not have a method �translated_cart_item_name�
159
  * Order completed emails sent in default currency
160
  * Language suffix (e.g. @en) not hidden for product attributes on the front end
161
  * Quick edit functionality issues fixed
162
+ * Fixed �Call to undefined method WC_Session_Handler::get()�
163
+ * Fatal error when updating the order status to �complete�
164
  * Currency is not converted when you switch language until you refresh the page.
165
+ * �Super Admin� not able to see the WCML menu
166
  * Checkout validation errors in default language instead of user language
167
+ * Fixes for compatibility with Tab manager: Can�t translate �Additional Information� tab title
168
  * Bug: SEO title & meta description changed to original
169
+ * Bug: 404 on �view my order� on secondary language using �language name added as a parameter�
170
  * Bug: Permalink placeholders appear translated when using default language different than English
171
  * Fixes for compatibility with Table Rate shipping: shipping classes not decoded correctly in multi-currency mode
172
+ * Bug: �show all products� link on WCML products page points to the wrong page � no products
173
+ * Bug fix: product page redirecting to homepage when the product post type slug was identical in different languages and �language added as a parameter� was set
174
  * Bug fixes related to File paths functionality (WooComemrce 2.1.x)
175
  * Bug: Product parents not synced between translations (grouped products)
176
  * Bug: Grouped products title incomplete
177
  * Bug: Db Error when saving translation of variable products with custom attributes
178
  * Bug: WooCommerce translated product attributes with spaces not showing
179
+ * Bug: Deactivated currency still appears if you maintain the default currency for that language to �Keep�.
180
  * Bug: Incorrect shipping value on translated page
181
  * Bug: Reports for products including only products in the current language (WooCommerce 2.1.x)
182
  * Bug: WooCommerce translated product attributes with spaces not showing
183
  * Bug: Problems creating translations for shop pages when existing pages were trashed
184
+ * Bug fix: Fatal error when Multi-currency is not enabled and �Table Rate Shipping� plugin is active
185
  * Fixed bug in compatibility with Tab Manager
186
  * Bug fix: Cart strings falling to default language after updating chosen shipping method
187
  * Bug fix: Reports not including selected product/category translations
221
  * Fixed bug: language names not localized on products editor page
222
  * Fixed bug: Can't set "Custom post type" to translate
223
  * Fixed bug: Translation fields not visible - In certain circumstances (e.g. search) the translation fields corresponding to the translated languages were missing
224
+ * Fixed alignment for �Update/Save� button in the products translation editor
225
  * Fixed bug: Default selection not copied to duplicate products
226
  * Fixed bug: Price doesn't change when change language on the cart page when set "I will manage the pricing in each currency myself"
227
  * Resolved one compatibility issue with Woosidebars
woocommerce_wpml.class.php CHANGED
@@ -16,6 +16,7 @@ class woocommerce_wpml {
16
  add_action('init', array($this, 'load_css_and_js'));
17
 
18
  $this->endpoints = new WCML_Endpoints;
 
19
  }
20
 
21
  function init(){
@@ -36,7 +37,7 @@ class woocommerce_wpml {
36
  require_once WCML_PLUGIN_PATH . '/inc/multi-currency-support.class.php';
37
  $this->multi_currency_support = new WCML_Multi_Currency_Support;
38
  require_once WCML_PLUGIN_PATH . '/inc/multi-currency.class.php';
39
- $this->multi_currency = new WCML_WC_MultiCurrency;
40
  require_once WCML_PLUGIN_PATH . '/inc/currency-switcher.class.php';
41
  $this->currency_switcher = new WCML_CurrencySwitcher;
42
  }else{
@@ -107,6 +108,21 @@ class woocommerce_wpml {
107
 
108
  //load WC translations
109
  add_action( 'icl_update_active_languages', array( $this, 'download_woocommerce_translations_for_active_languages' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  }
111
 
112
  function translate_product_slug(){
@@ -115,23 +131,22 @@ class woocommerce_wpml {
115
  if(!defined('WOOCOMMERCE_VERSION') || (!isset($GLOBALS['ICL_Pro_Translation']) || is_null($GLOBALS['ICL_Pro_Translation']))){
116
  return;
117
  }
118
- $permalinks = get_option('woocommerce_permalinks', array('product_base' => ''));
119
 
120
  $slug = get_option('woocommerce_product_slug') != false ? get_option('woocommerce_product_slug') : 'product';
121
 
122
- $string = $wpdb->get_row($wpdb->prepare("SELECT id, status FROM {$wpdb->prefix}icl_strings WHERE name = %s AND value = %s ", 'URL slug: ' . $slug, $slug));
123
 
124
  if(!$string){
125
  icl_register_string('WordPress', 'URL slug: ' . $slug, $slug);
126
- $string = $wpdb->get_row($wpdb->prepare("SELECT id, status FROM {$wpdb->prefix}icl_strings WHERE name = %s AND value = %s ", 'URL slug: ' . $slug, $slug));
127
  }
128
-
129
  if(empty($sitepress_settings['posts_slug_translation']['on']) || empty($sitepress_settings['posts_slug_translation']['types'][$slug])){
130
  $iclsettings['posts_slug_translation']['on'] = 1;
131
  $iclsettings['posts_slug_translation']['types'][$slug] = 1;
132
- $sitepress->save_settings($iclsettings);
133
  }
134
-
135
  }
136
 
137
  function get_settings(){
@@ -214,7 +229,7 @@ class woocommerce_wpml {
214
 
215
  $this->settings['set_up'] = 1;
216
  $this->update_settings();
217
-
218
 
219
  }
220
 
@@ -223,7 +238,7 @@ class woocommerce_wpml {
223
  $this->settings['downloaded_translations_for_wc'] = 1;
224
  $this->update_settings();
225
  }
226
-
227
  require_once WCML_PLUGIN_PATH . '/inc/multi-currency.class.php';
228
  WCML_WC_MultiCurrency::install();
229
 
@@ -508,14 +523,11 @@ class woocommerce_wpml {
508
  if(isset($value['attribute_base']) && $value['attribute_base']){
509
  icl_register_string('URL attribute slugs - ' . trim($value['attribute_base'] ,'/'), 'Url attribute slug: ' . trim($value['attribute_base'] ,'/'), trim($value['attribute_base'] ,'/'));
510
  }
511
-
512
  if(isset($value['product_base']) && !$value['product_base']){
513
  $value['product_base'] = get_option('woocommerce_product_slug') != false ? get_option('woocommerce_product_slug') : 'product';
514
- }else{
515
- $value['product_base'] = trim($value['product_base'], '/');
516
  }
517
 
518
-
519
  return $value;
520
 
521
  }
@@ -540,7 +552,12 @@ class woocommerce_wpml {
540
  }
541
  }
542
 
543
- //download translations for WC
 
 
 
 
 
544
  function download_woocommerce_translations( $lang_code ){
545
  global $sitepress;
546
 
@@ -552,6 +569,7 @@ class woocommerce_wpml {
552
  include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
553
  require_once( ABSPATH . 'wp-admin/includes/file.php' );
554
  require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
 
555
 
556
  $url = 'update-core.php?action=do-translation-upgrade';
557
  $nonce = 'upgrade-translations';
@@ -572,11 +590,17 @@ class woocommerce_wpml {
572
  $upgr_object[0]->autoupdate = 1;
573
 
574
  $upgrader->bulk_upgrade( $upgr_object );
 
 
575
  }
576
 
577
  }
578
 
579
 
 
 
 
 
580
  function download_woocommerce_translations_for_active_languages(){
581
  global $sitepress;
582
 
@@ -593,4 +617,162 @@ class woocommerce_wpml {
593
  $sitepress->switch_lang( $current_language );
594
  }
595
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  }
16
  add_action('init', array($this, 'load_css_and_js'));
17
 
18
  $this->endpoints = new WCML_Endpoints;
19
+ add_action('widgets_init', array($this, 'register_widget'));
20
  }
21
 
22
  function init(){
37
  require_once WCML_PLUGIN_PATH . '/inc/multi-currency-support.class.php';
38
  $this->multi_currency_support = new WCML_Multi_Currency_Support;
39
  require_once WCML_PLUGIN_PATH . '/inc/multi-currency.class.php';
40
+ $this->multi_currency = new WCML_WC_MultiCurrency;
41
  require_once WCML_PLUGIN_PATH . '/inc/currency-switcher.class.php';
42
  $this->currency_switcher = new WCML_CurrencySwitcher;
43
  }else{
108
 
109
  //load WC translations
110
  add_action( 'icl_update_active_languages', array( $this, 'download_woocommerce_translations_for_active_languages' ) );
111
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_for_update' ), 11 );
112
+ add_filter( 'upgrader_pre_download', array( $this, 'version_update' ), 10, 2 );
113
+ add_action( 'admin_notices', array( $this, 'translation_upgrade_notice' ) );
114
+ add_action( 'wp_ajax_hide_wcml_translations_message', array($this, 'hide_wcml_translations_message') );
115
+
116
+ }
117
+
118
+ function register_widget(){
119
+
120
+ $settings = $this->get_settings();
121
+ if($settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT){
122
+ require_once WCML_PLUGIN_PATH . '/inc/currency-switcher-widget.class.php';
123
+ register_widget('WC_Currency_Switcher_Widget');
124
+ }
125
+
126
  }
127
 
128
  function translate_product_slug(){
131
  if(!defined('WOOCOMMERCE_VERSION') || (!isset($GLOBALS['ICL_Pro_Translation']) || is_null($GLOBALS['ICL_Pro_Translation']))){
132
  return;
133
  }
 
134
 
135
  $slug = get_option('woocommerce_product_slug') != false ? get_option('woocommerce_product_slug') : 'product';
136
 
137
+ $string = $wpdb->get_row($wpdb->prepare("SELECT id,status FROM {$wpdb->prefix}icl_strings WHERE name = %s AND value = %s ", 'URL slug: ' . $slug, $slug));
138
 
139
  if(!$string){
140
  icl_register_string('WordPress', 'URL slug: ' . $slug, $slug);
141
+ $string = $wpdb->get_row($wpdb->prepare("SELECT id,status FROM {$wpdb->prefix}icl_strings WHERE name = %s AND value = %s ", 'URL slug: ' . $slug, $slug));
142
  }
143
+
144
  if(empty($sitepress_settings['posts_slug_translation']['on']) || empty($sitepress_settings['posts_slug_translation']['types'][$slug])){
145
  $iclsettings['posts_slug_translation']['on'] = 1;
146
  $iclsettings['posts_slug_translation']['types'][$slug] = 1;
147
+ $sitepress->save_settings($iclsettings);
148
  }
149
+
150
  }
151
 
152
  function get_settings(){
229
 
230
  $this->settings['set_up'] = 1;
231
  $this->update_settings();
232
+
233
 
234
  }
235
 
238
  $this->settings['downloaded_translations_for_wc'] = 1;
239
  $this->update_settings();
240
  }
241
+
242
  require_once WCML_PLUGIN_PATH . '/inc/multi-currency.class.php';
243
  WCML_WC_MultiCurrency::install();
244
 
523
  if(isset($value['attribute_base']) && $value['attribute_base']){
524
  icl_register_string('URL attribute slugs - ' . trim($value['attribute_base'] ,'/'), 'Url attribute slug: ' . trim($value['attribute_base'] ,'/'), trim($value['attribute_base'] ,'/'));
525
  }
526
+
527
  if(isset($value['product_base']) && !$value['product_base']){
528
  $value['product_base'] = get_option('woocommerce_product_slug') != false ? get_option('woocommerce_product_slug') : 'product';
 
 
529
  }
530
 
 
531
  return $value;
532
 
533
  }
552
  }
553
  }
554
 
555
+ /**
556
+ * Automatically download translations for WC ( when user install WCML ( from 3.3.3) / add new language in WPML )
557
+ *
558
+ * @param string $lang_code Language code
559
+ *
560
+ */
561
  function download_woocommerce_translations( $lang_code ){
562
  global $sitepress;
563
 
569
  include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
570
  require_once( ABSPATH . 'wp-admin/includes/file.php' );
571
  require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
572
+ require_once( ABSPATH . 'wp-admin/includes/template.php' );
573
 
574
  $url = 'update-core.php?action=do-translation-upgrade';
575
  $nonce = 'upgrade-translations';
590
  $upgr_object[0]->autoupdate = 1;
591
 
592
  $upgrader->bulk_upgrade( $upgr_object );
593
+
594
+ $this->save_translation_version( $locale );
595
  }
596
 
597
  }
598
 
599
 
600
+ /*
601
+ * Automatically download translations for WC for active languages
602
+ *
603
+ */
604
  function download_woocommerce_translations_for_active_languages(){
605
  global $sitepress;
606
 
617
  $sitepress->switch_lang( $current_language );
618
  }
619
 
620
+
621
+ /*
622
+ * Check for WC language updates
623
+ *
624
+ * @param object $data Transient update data
625
+ *
626
+ * @return object
627
+ */
628
+ function check_for_update( $data ){
629
+ global $sitepress;
630
+
631
+ if( class_exists( 'WC_Language_Pack_Upgrader' ) ){
632
+
633
+ $wc_upgrader_class = new WC_Language_Pack_Upgrader();
634
+
635
+ $active_languages = $sitepress->get_active_languages();
636
+ $current_language = $sitepress->get_current_language();
637
+
638
+ foreach( $active_languages as $language ){
639
+ if( $language['code'] == 'en' )
640
+ continue;
641
+
642
+ $sitepress->switch_lang( $language['code'], true );
643
+
644
+ $locale = get_locale();
645
+
646
+ if ( $this->has_available_update( $locale, $wc_upgrader_class ) && isset( $data->translations ) ) {
647
+
648
+ $data->translations[] = array(
649
+ 'type' => 'plugin',
650
+ 'slug' => 'woocommerce',
651
+ 'language' => $locale,
652
+ 'version' => WC_VERSION,
653
+ 'updated' => date( 'Y-m-d H:i:s' ),
654
+ 'package' => $wc_upgrader_class->get_language_package_uri(),
655
+ 'autoupdate' => 1
656
+ );
657
+
658
+ }
659
+
660
+ }
661
+
662
+ $sitepress->switch_lang( $current_language, true );
663
+
664
+ }
665
+
666
+ return $data;
667
+ }
668
+
669
+
670
+ /*
671
+ * Update the WC language version in database
672
+ *
673
+ *
674
+ * @param bool $reply Whether to bail without returning the package (default: false)
675
+ * @param string $package Package URL
676
+ *
677
+ * @return bool
678
+ */
679
+ function version_update( $reply, $package ) {
680
+
681
+ $notices = maybe_unserialize( get_option( 'wcml_translations_upgrade_notice' ) );
682
+
683
+ if( !is_array( $notices ) ){
684
+ return $reply;
685
+ }
686
+
687
+ foreach( $notices as $key => $locale){
688
+ if( strstr( $package, 'woocommerce-language-packs') && strstr( $package, $locale) ){
689
+
690
+ $this->save_translation_version( $locale, $key );
691
+
692
+ }
693
+ }
694
+
695
+ return $reply;
696
+ }
697
+
698
+
699
+ function save_translation_version( $locale, $key = false ){
700
+
701
+ $notices = maybe_unserialize( get_option( 'wcml_translations_upgrade_notice' ) );
702
+
703
+ // Update the language pack version
704
+ update_option( 'woocommerce_language_pack_version_'.$locale, array( WC_VERSION, $locale ) );
705
+
706
+ if( is_array( $notices ) ){
707
+
708
+ if( !$key )
709
+ $key = array_search( $locale, $notices );
710
+
711
+ // Remove the translation upgrade notice
712
+ unset( $notices[ $key ] );
713
+
714
+ update_option( 'wcml_translations_upgrade_notice', $notices );
715
+
716
+ }
717
+
718
+ }
719
+
720
+ /*
721
+ * Check if has available translation update
722
+ *
723
+ * @param string $locale Locale code
724
+ * @param object $wc_upgrader_class WC_Language_Pack_Upgrader class object
725
+ *
726
+ * @return bool
727
+ */
728
+ function has_available_update( $locale, $wc_upgrader_class ) {
729
+ $version = get_option( 'woocommerce_language_pack_version_'.$locale, array( '0', $locale ) );
730
+
731
+ $notices = maybe_unserialize( get_option( 'wcml_translations_upgrade_notice' ) );
732
+
733
+ if ( 'en_US' !== $locale && ( ! is_array( $version ) || version_compare( $version[0], WC_VERSION, '<' ) || $version[1] !== $locale ) ) {
734
+ if ( $wc_upgrader_class->check_if_language_pack_exists() ) {
735
+
736
+ if( !$notices || !in_array( $locale, $notices )){
737
+ $notices[] = $locale;
738
+
739
+ update_option( 'wcml_translations_upgrade_notice', $notices );
740
+ update_option( 'hide_wcml_translations_message', 0 );
741
+ }
742
+
743
+ return true;
744
+ } else {
745
+ // Updated the woocommerce_language_pack_version to avoid searching translations for this release again
746
+ update_option( 'woocommerce_language_pack_version_'.$locale, array( WC_VERSION, $locale ) );
747
+ }
748
+ }
749
+
750
+ return false;
751
+ }
752
+
753
+
754
+ /*
755
+ * Display Translations upgrade notice message
756
+ */
757
+ function translation_upgrade_notice(){
758
+ $screen = get_current_screen();
759
+
760
+ $notices = maybe_unserialize( get_option( 'wcml_translations_upgrade_notice' ) );
761
+
762
+ if ( 'update-core' !== $screen->id && !empty ( $notices ) && !get_option( 'hide_wcml_translations_message' ) ) {
763
+ include( 'menu/sub/notice-translation-upgrade.php' );
764
+ }
765
+ }
766
+
767
+ /*
768
+ * Hide Translations upgrade notice message ( update option in DB )
769
+ */
770
+ function hide_wcml_translations_message(){
771
+ if( wp_verify_nonce( $_REQUEST['wcml_nonce'], 'hide_wcml_translations_message' ) ){
772
+ update_option( 'hide_wcml_translations_message', true );
773
+ }
774
+
775
+ die();
776
+ }
777
+
778
  }
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.3.4
9
  */
10
 
11
 
12
  if(defined('WCML_VERSION')) return;
13
- define('WCML_VERSION', '3.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
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);