WooCommerce Multilingual – run WooCommerce with WPML - Version 3.6

Version Description

  • Added the ability to edit the slugs of the translated products in the products editor
  • Added the option to show only products with custom prices on the front end
  • Performance improvements: fewer db queries, caching. Up to 40% faster on large sites.
  • Support for the 'lang' parameter in WooCommerce REST API calls
  • Option to hide the default currency selector on the product page
  • Bug fix: Fixed a design issue on the 'connect with translation' pop-up on products.
  • Bug fix: Accessing the source content in the WooCommerce Multilingual product translation content editor was not possible sometimes.
  • Bug fix: 'Invisible' products were showing as links in the cart instead of just names.
  • Bug fix: The cart_widget.js code was always loaded.
  • Bug fix: Screen Options & Check All not working on WooCommerce Orders page
  • Bug fix: Sometimes the IPN Url sent to Paypal was wrong causing a 404 error after the payment was complete
  • Bug fix: Translated endpoint pages were sometimes returning 404
  • Bug fix: When using a default language different than English, the product permalink base was not in English.
Download this release

Release Info

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

Code changes from version 3.5.5 to 3.6

Files changed (53) hide show
  1. assets/css/currency-switcher.css +4 -0
  2. assets/css/management.css +9 -1
  3. assets/css/wcml-wc-integration.css +2 -1
  4. assets/js/cart_widget.js +0 -5
  5. assets/js/scripts.js +45 -23
  6. compatibility/assets/css/wcml-bookings.css +52 -0
  7. compatibility/assets/js/wcml-bookings.js +91 -0
  8. compatibility/templates/wc_bookings_custom_box_html.php +30 -0
  9. compatibility/wc_bookings.class.php +1368 -0
  10. compatibility/wc_extra_product_options.class.php +1 -1
  11. compatibility/wc_product_addons.class.php +1 -1
  12. compatibility/wc_tab_manager.class.php +9 -7
  13. inc/ajax-setup.class.php +20 -11
  14. inc/compatibility.class.php +6 -0
  15. inc/currency-switcher-widget.class.php +1 -1
  16. inc/dependencies.class.php +1 -1
  17. inc/endpoints.class.php +8 -0
  18. inc/multi-currency-support.class.php +51 -10
  19. inc/multi-currency.class.php +8 -2
  20. inc/products.class.php +136 -20
  21. inc/requests.class.php +5 -3
  22. inc/store-pages.class.php +5 -0
  23. inc/terms.class.php +1 -1
  24. inc/upgrade.class.php +119 -107
  25. inc/wc-rest-api-support.php +38 -0
  26. inc/wc-strings.class.php +8 -3
  27. locale/wpml-wcml-ar.mo +0 -0
  28. locale/wpml-wcml-de_DE.mo +0 -0
  29. locale/wpml-wcml-el.mo +0 -0
  30. locale/wpml-wcml-es_ES.mo +0 -0
  31. locale/wpml-wcml-fr_FR.mo +0 -0
  32. locale/wpml-wcml-he_IL.mo +0 -0
  33. locale/wpml-wcml-it_IT.mo +0 -0
  34. locale/wpml-wcml-ja.mo +0 -0
  35. locale/wpml-wcml-ko_KR.mo +0 -0
  36. locale/wpml-wcml-nl_NL.mo +0 -0
  37. locale/wpml-wcml-pl_PL.mo +0 -0
  38. locale/wpml-wcml-pt_BR.mo +0 -0
  39. locale/wpml-wcml-pt_PT.mo +0 -0
  40. locale/wpml-wcml-ru_RU.mo +0 -0
  41. locale/wpml-wcml-sv_SE.mo +0 -0
  42. locale/wpml-wcml-vi.mo +0 -0
  43. locale/wpml-wcml-zh_CN.mo +0 -0
  44. locale/wpml-wcml-zh_TW.mo +0 -0
  45. menu/management.php +4 -4
  46. menu/plugins.php +1 -1
  47. menu/sub/currency-switcher-options.php +11 -0
  48. menu/sub/product-data.php +41 -21
  49. menu/sub/products.php +2 -2
  50. menu/sub/settings.php +22 -25
  51. readme.txt +17 -2
  52. woocommerce_wpml.class.php +31 -22
  53. wpml-woocommerce.php +2 -2
assets/css/currency-switcher.css CHANGED
@@ -10,6 +10,10 @@ ul.wcml_currency_switcher li{
10
  border: 1px solid #cdcdcd;
11
  }
12
 
 
 
 
 
13
  ul.wcml_currency_switcher.curr_list_vertical{
14
  border-top: 1px solid #cdcdcd;
15
  display: inline-block;
10
  border: 1px solid #cdcdcd;
11
  }
12
 
13
+ .wcml-active-currency{
14
+ background-color: #E5E5E5;
15
+ }
16
+
17
  ul.wcml_currency_switcher.curr_list_vertical{
18
  border-top: 1px solid #cdcdcd;
19
  display: inline-block;
assets/css/management.css CHANGED
@@ -975,4 +975,12 @@ input[name="wcml_curr_template"]{
975
  }
976
  .wcml_miss_lang p:first-child{
977
  float:left;
978
- }
 
 
 
 
 
 
 
 
975
  }
976
  .wcml_miss_lang p:first-child{
977
  float:left;
978
+ }
979
+ #display_custom_prices_select{
980
+ display: inline-block;
981
+ width: 100%;
982
+ }
983
+ .edit_slug_input,
984
+ .edit_slug_hide_link{
985
+ display: none;
986
+ }
assets/css/wcml-wc-integration.css CHANGED
@@ -1,2 +1,3 @@
1
  .wcml_currency_options_menu_item{}
2
- .wcml_currency_options_menu_item.selected{font-weight: bold; text-decoration: none; color:#333;}
 
1
  .wcml_currency_options_menu_item{}
2
+ .wcml_currency_options_menu_item.selected{font-weight: bold; text-decoration: none; color:#333;}
3
+ #connect_translations_dialog,#connect_translations_dialog_confirm{float: left;}
assets/js/cart_widget.js DELETED
@@ -1,5 +0,0 @@
1
- jQuery(document).ready(function($){
2
- sessionStorage.removeItem("wc_cart_hash");
3
- sessionStorage.removeItem("wc_fragments");
4
- });
5
-
 
 
 
 
 
assets/js/scripts.js CHANGED
@@ -12,7 +12,7 @@ jQuery(document).ready(function($){
12
  discard = false;
13
  });
14
 
15
- $('.wcml-section input[type="radio"],#wcml_products_sync_date,#wcml_products_sync_order').click(function(){
16
  discard = true;
17
  $(this).closest('.wcml-section').find('.button-wrap input').css("border-color","#1e8cbe");
18
  });
@@ -168,28 +168,36 @@ jQuery(document).ready(function($){
168
  //update status block
169
  $('.translations_statuses.prid_'+product_id).html(response.status);
170
 
 
 
 
 
 
 
 
 
171
 
172
  //update images block
173
  if(language in response.images){
174
- var value = response.images[language];
175
- field.closest('.outer').find('tr[rel="'+language+'"] .prod_images').closest('td').html(value).find('.prod_images').css('display','none');
176
- }
177
 
178
- //update variations block
179
 
180
- if(typeof response.variations !== "undefined" && (language in response.variations)){
181
- var value = response.variations[language];
182
- field.closest('.outer').find('tr[rel="'+language+'"] .prod_variations').closest('td').html(value).find('.prod_variations').css('display','none');
183
- }
184
 
185
- //set def data
186
- field.closest('.outer').find('input').each(function(){
187
- $(this).data('def',$(this).val());
188
- });
189
 
190
 
191
 
192
- field.val($('#wcml_product_update_button_label').html());
193
 
194
  }
195
  field.parent().find('.wcml_spinner').hide();
@@ -488,15 +496,15 @@ jQuery(document).ready(function($){
488
 
489
  });
490
 
491
- $(document).on('click','.cleditorButton',function(){
492
- if($(this).closest('.cleditorMain').find('textarea').is(':visible')){
493
- $(this).closest('.cleditorMain').find('textarea').hide();
494
- $(this).closest('.cleditorMain').find('iframe').show();
495
- }else{
496
- $(this).closest('.cleditorMain').find('textarea').show();
497
- $(this).closest('.cleditorMain').find('iframe').hide();
498
- }
499
- });
500
 
501
  $(document).on('click','.wcml_close_cross,.wcml_popup_cancel',function(){
502
  $(".wcml_fade").hide();
@@ -563,6 +571,18 @@ jQuery(document).ready(function($){
563
 
564
  });
565
 
 
 
 
 
 
 
 
 
 
 
 
 
566
 
567
  //wc 2.0.*
568
  if($('.wcml_file_paths').size()>0){
@@ -752,11 +772,13 @@ jQuery(document).ready(function($){
752
  $('.currencies-table-content').fadeOut();
753
  $('.wcml_add_currency').fadeOut();
754
  $('#currency-switcher').fadeOut();
 
755
  }else{
756
  $('.currencies-table-content').fadeIn();
757
  $('.wcml_add_currency').fadeIn();
758
  $('#currency-switcher').fadeIn();
759
  $('#multi-currency-per-language-details').fadeIn();
 
760
  }
761
 
762
  })
12
  discard = false;
13
  });
14
 
15
+ $('.wcml-section input[type="radio"],#wcml_products_sync_date,#wcml_products_sync_order,#display_custom_prices').click(function(){
16
  discard = true;
17
  $(this).closest('.wcml-section').find('.button-wrap input').css("border-color","#1e8cbe");
18
  });
168
  //update status block
169
  $('.translations_statuses.prid_'+product_id).html(response.status);
170
 
171
+ //update slug
172
+ if( field.closest('.outer').find('.edit_slug_warning').size() >0 ){
173
+ field.closest('.outer').find('input[name="post_name_'+language+'"]').removeAttr('disabled').removeClass('hidden');
174
+ field.closest('.outer').find('.edit_slug_show_link').removeClass('hidden');
175
+ field.closest('.outer').find('.edit_slug_hide_link').removeClass('hidden');
176
+ field.closest('.outer').find('.edit_slug_warning').remove();
177
+ }
178
+ field.closest('.outer').find('input[name="post_name_'+language+'"]').val(response.slug);
179
 
180
  //update images block
181
  if(language in response.images){
182
+ var value = response.images[language];
183
+ field.closest('.outer').find('tr[rel="'+language+'"] .prod_images').closest('td').html(value).find('.prod_images').css('display','none');
184
+ }
185
 
186
+ //update variations block
187
 
188
+ if(typeof response.variations !== "undefined" && (language in response.variations)){
189
+ var value = response.variations[language];
190
+ field.closest('.outer').find('tr[rel="'+language+'"] .prod_variations').closest('td').html(value).find('.prod_variations').css('display','none');
191
+ }
192
 
193
+ //set def data
194
+ field.closest('.outer').find('input').each(function(){
195
+ $(this).data('def',$(this).val());
196
+ });
197
 
198
 
199
 
200
+ field.val($('#wcml_product_update_button_label').html());
201
 
202
  }
203
  field.parent().find('.wcml_spinner').hide();
496
 
497
  });
498
 
499
+ $(document).on('click','.cleditorButton',function(){
500
+ if($(this).closest('.cleditorMain').find('textarea').is(':visible')){
501
+ $(this).closest('.cleditorMain').find('textarea').hide();
502
+ $(this).closest('.cleditorMain').find('iframe').show();
503
+ }else{
504
+ $(this).closest('.cleditorMain').find('textarea').show();
505
+ $(this).closest('.cleditorMain').find('iframe').hide();
506
+ }
507
+ });
508
 
509
  $(document).on('click','.wcml_close_cross,.wcml_popup_cancel',function(){
510
  $(".wcml_fade").hide();
571
 
572
  });
573
 
574
+ $(document).on('click','.edit_slug_show_link,.edit_slug_hide_link',function(){
575
+ if($(this).closest('div').find('.edit_slug_input').is(':visible')){
576
+ $(this).closest('div').find('.edit_slug_input').hide();
577
+ $(this).closest('div').find('.edit_slug_hide_link').hide();
578
+ $(this).closest('div').find('.edit_slug_show_link').show();
579
+ }else{
580
+ $(this).closest('div').find('.edit_slug_input').show();
581
+ $(this).closest('div').find('.edit_slug_hide_link').show();
582
+ $(this).closest('div').find('.edit_slug_show_link').hide();
583
+ }
584
+ });
585
+
586
 
587
  //wc 2.0.*
588
  if($('.wcml_file_paths').size()>0){
772
  $('.currencies-table-content').fadeOut();
773
  $('.wcml_add_currency').fadeOut();
774
  $('#currency-switcher').fadeOut();
775
+ $('#display_custom_prices_select').fadeOut();
776
  }else{
777
  $('.currencies-table-content').fadeIn();
778
  $('.wcml_add_currency').fadeIn();
779
  $('#currency-switcher').fadeIn();
780
  $('#multi-currency-per-language-details').fadeIn();
781
+ $('#display_custom_prices_select').fadeIn();
782
  }
783
 
784
  })
compatibility/assets/css/wcml-bookings.css ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wcml_custom_cost_field{
2
+ display: none;
3
+ clear: both;
4
+ }
5
+
6
+ .wcml_bookings_range_block,
7
+ .wcml_bookings_person_block,
8
+ .wcml_bookings_resource_block{
9
+ padding: 5px 0;
10
+ display: -webkit-flex;
11
+ display: flex;
12
+ -webkit-flex-direction: row;
13
+ flex-direction: row;
14
+ }
15
+
16
+ .wcml_bookings_range_block label,
17
+ .wcml_bookings_person_block label,
18
+ .wcml_bookings_resource_block label{
19
+ width: auto;
20
+ margin: 0;
21
+ padding: 6px 7px;
22
+ }
23
+
24
+ .wcml_wc_booking_cost_field label,
25
+ .wcml_wc_booking_base_cost_field label,
26
+ .wcml_wc_display_cost_field label{
27
+ text-align: right;
28
+ margin-left: -160px;
29
+ }
30
+
31
+ .wcml_custom_costs{
32
+ padding: 9px 9px 0;
33
+ display: inline-block;
34
+ width: 100%;
35
+ }
36
+
37
+ .wcml_custom_costs label{
38
+ width: auto;
39
+ margin: 0;
40
+ float: left;
41
+ }
42
+
43
+ .wcml_custom_costs input{
44
+ width: 16px;
45
+ clear: both;
46
+ margin: 2px 5px 2px 0;
47
+ float: left;
48
+ }
49
+ input.wcml_bookings_custom_price,
50
+ #bookings_pricing .table_grid table td input.wcml_bookings_custom_price{
51
+ background-color: #F5F2E1;
52
+ }
compatibility/assets/js/wcml-bookings.js ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( document ).ready( function( $ ){
2
+
3
+ if( $( '.wcml_custom_costs_input:checked' ).val() == 1 ){
4
+
5
+ $( '.wcml_custom_cost_field' ).show();
6
+
7
+ }
8
+
9
+ $(document).on( 'change', '.wcml_custom_costs_input', function(){
10
+
11
+ if( $(this).val() == 1 ){
12
+
13
+ $( '.wcml_custom_cost_field' ).show();
14
+
15
+ }else{
16
+
17
+ $( '.wcml_custom_cost_field' ).hide();
18
+
19
+ }
20
+
21
+ });
22
+
23
+ $(document).on( 'mouseout', '.add_row', function(){
24
+
25
+ if( $( '.wcml_custom_costs_input:checked' ).val() == 1 ) {
26
+
27
+ $( '.wcml_custom_cost_field' ).show();
28
+
29
+ }
30
+
31
+ });
32
+
33
+ $(document).on( 'mouseout', '.add_person', function(){
34
+
35
+ if( $( '.wcml_custom_costs_input:checked' ).val() == 1 ) {
36
+
37
+ setTimeout(
38
+ function() {
39
+ $( '.wcml_custom_cost_field' ).show();
40
+ }, 3000);
41
+
42
+ }
43
+
44
+ });
45
+
46
+
47
+ //lock fields
48
+ if( lock_fields == 1 ){
49
+
50
+ $('#bookings_pricing input[type="number"], #bookings_resources input[type="number"], #bookings_availability input[type="number"], #bookings_availability input[type="text"], #bookings_persons input[type="number"]').each(function(){
51
+ $(this).attr('readonly','readonly');
52
+ $(this).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
53
+ });
54
+
55
+
56
+ $('#bookings_pricing select, #bookings_resources select, #bookings_availability select,#bookings_persons input[type="checkbox"]').each(function(){
57
+ $(this).attr('disabled','disabled');
58
+ $(this).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
59
+ });
60
+
61
+ var ids = [ '_wc_booking_has_resources', '_wc_booking_has_persons', '_wc_booking_duration_type', '_wc_booking_duration', '_wc_booking_duration_unit', '_wc_booking_calendar_display_mode', '_wc_booking_requires_confirmation', '_wc_booking_user_can_cancel'];
62
+
63
+ for (i = 0; i < ids.length; i++) {
64
+ $('#'+ids[i]).attr('disabled','disabled');
65
+ $('#'+ids[i]).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
66
+ }
67
+
68
+ var buttons = [ 'add_resource', 'add_row' ];
69
+
70
+ for (i = 0; i < buttons.length; i++) {
71
+ $('.'+buttons[i]).attr('disabled','disabled');
72
+ $('.'+buttons[i]).unbind('click');
73
+ $('.'+buttons[i]).after($('.wcml_lock_img').clone().removeClass('wcml_lock_img').show());
74
+ }
75
+
76
+ $('form#post input[type="submit"]').click(function(){
77
+
78
+ for (i = 0; i < ids.length; i++) {
79
+ $('#'+ids[i]).removeAttr('disabled');
80
+ }
81
+
82
+ $('#bookings_pricing select, #bookings_resources select, #bookings_availability select,#bookings_persons input[type="checkbox"]').each(function(){
83
+ $(this).removeAttr('disabled');
84
+ });
85
+
86
+ });
87
+
88
+
89
+ }
90
+ });
91
+
compatibility/templates/wc_bookings_custom_box_html.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if( isset( $template_data[ 'resources' ] ) ): ?>
2
+ <?php foreach( $template_data[ 'resources' ] as $original_resource_id => $trnsl_resource_id ): ?>
3
+ <tr>
4
+ <td>
5
+ <?php if( !$template_data[ 'original' ] ): ?>
6
+ <input type="hidden" name="<?php echo $template_data[ 'product_content' ].'_'.$template_data['lang'].'[id][]'; ?>" value="<?php echo $trnsl_resource_id; ?>" />
7
+ <?php if( empty( $trnsl_resource_id ) ): ?>
8
+ <input type="hidden" name="<?php echo $template_data[ 'product_content' ].'_'.$template_data['lang'].'[orig_id][]'; ?>" value="<?php echo $original_resource_id; ?>" />
9
+ <?php endif;?>
10
+ <?php endif;?>
11
+ <textarea rows="1" <?php if( !$template_data['original'] ): ?>name="<?php echo $template_data['product_content'].'_'.$template_data['lang'].'[title][]'; ?>"<?php endif;?> <?php if( $template_data['original'] ): ?> disabled="disabled"<?php endif;?>><?php echo $template_data[ 'original' ]? get_the_title( $original_resource_id ): get_the_title( $trnsl_resource_id ); ?></textarea>
12
+ </td>
13
+ </tr>
14
+ <?php endforeach; ?>
15
+ <?php elseif( isset( $template_data[ 'persons' ] ) ): ?>
16
+ <?php foreach( $template_data[ 'persons' ] as $original_person_id => $trnsl_person_id ): ?>
17
+ <tr>
18
+ <td>
19
+ <?php if( !$template_data[ 'original' ] ): ?>
20
+ <input type="hidden" name="<?php echo $template_data[ 'product_content' ].'_'.$template_data['lang'].'[id][]'; ?>" value="<?php echo $trnsl_person_id; ?>" />
21
+ <?php if( empty( $trnsl_person_id ) ): ?>
22
+ <input type="hidden" name="<?php echo $template_data[ 'product_content' ].'_'.$template_data['lang'].'[orig_id][]'; ?>" value="<?php echo $original_person_id; ?>" />
23
+ <?php endif;?>
24
+ <?php endif;?>
25
+ <textarea rows="1" <?php if( !$template_data['original'] ): ?>name="<?php echo $template_data['product_content'].'_'.$template_data['lang'].'[title][]'; ?>"<?php endif;?> <?php if( $template_data['original'] ): ?> disabled="disabled"<?php endif;?>><?php echo $template_data[ 'original' ]? get_the_title( $original_person_id ): get_the_title( $trnsl_person_id ); ?></textarea>
26
+ <textarea rows="1" <?php if( !$template_data['original'] ): ?>name="<?php echo $template_data['product_content'].'_'.$template_data['lang'].'[description][]'; ?>"<?php endif;?> <?php if( $template_data['original'] ): ?> disabled="disabled"<?php endif;?>><?php echo $template_data[ 'original' ]? get_post( $original_person_id )->post_excerpt: $template_data[ 'translation_exist' ] ? get_post( $trnsl_person_id )->post_excerpt : ''; ?></textarea>
27
+ </td>
28
+ </tr>
29
+ <?php endforeach; ?>
30
+ <?php endif; ?>
compatibility/wc_bookings.class.php ADDED
@@ -0,0 +1,1368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WCML_Bookings{
4
+
5
+ function __construct(){
6
+
7
+ add_action( 'woocommerce_bookings_after_booking_base_cost' , array( $this, 'wcml_price_field_after_booking_base_cost' ) );
8
+ add_action( 'woocommerce_bookings_after_booking_block_cost' , array( $this, 'wcml_price_field_after_booking_block_cost' ) );
9
+ add_action( 'woocommerce_bookings_after_display_cost' , array( $this, 'wcml_price_field_after_display_cost' ) );
10
+ add_action( 'woocommerce_bookings_after_booking_pricing_base_cost' , array( $this, 'wcml_price_field_after_booking_pricing_base_cost' ), 10, 2 );
11
+ add_action( 'woocommerce_bookings_after_booking_pricing_cost' , array( $this, 'wcml_price_field_after_booking_pricing_cost' ), 10, 2 );
12
+ add_action( 'woocommerce_bookings_after_person_cost' , array( $this, 'wcml_price_field_after_person_cost' ) );
13
+ add_action( 'woocommerce_bookings_after_person_block_cost' , array( $this, 'wcml_price_field_after_person_block_cost' ) );
14
+ add_action( 'woocommerce_bookings_after_resource_cost' , array( $this, 'wcml_price_field_after_resource_cost' ), 10, 2 );
15
+ add_action( 'woocommerce_bookings_after_resource_block_cost' , array( $this, 'wcml_price_field_after_resource_block_cost' ), 10, 2 );
16
+ add_action( 'woocommerce_bookings_after_bookings_pricing' , array( $this, 'after_bookings_pricing' ) );
17
+
18
+ add_action( 'admin_footer', array( $this, 'load_assets' ) );
19
+
20
+ add_action( 'save_post', array( $this, 'save_custom_costs' ), 11, 2 );
21
+ add_action( 'wcml_before_sync_product', array( $this, 'sync_booking_data' ), 10, 2 );
22
+
23
+ add_filter( 'update_post_metadata', array( $this, 'update_wc_booking_costs' ), 10, 5 );
24
+
25
+ add_filter( 'get_post_metadata', array( $this, 'filter_wc_booking_cost' ), 10, 4 );
26
+ add_filter( 'woocommerce_bookings_process_cost_rules_cost', array( $this, 'wc_bookings_process_cost_rules_cost' ), 10, 3 );
27
+ add_filter( 'woocommerce_bookings_process_cost_rules_base_cost', array( $this, 'wc_bookings_process_cost_rules_base_cost' ), 10, 3 );
28
+
29
+ add_filter( 'wcml_multi_currency_is_ajax', array( $this, 'wcml_multi_currency_is_ajax' ) );
30
+
31
+ add_filter( 'wcml_cart_contents_not_changed', array( $this, 'filter_bundled_product_in_cart_contents' ), 10, 3 );
32
+
33
+ add_action( 'after_woocommerce_bookings_create_booking_page', array( $this, 'booking_currency_dropdown' ) );
34
+ add_action( 'init', array( $this, 'set_booking_currency') );
35
+ add_action( 'wp_ajax_wcml_booking_set_currency', array( $this, 'set_booking_currency_ajax' ) );
36
+ add_action( 'woocommerce_bookings_create_booking_page_add_order_item', array( $this, 'set_order_currency_on_create_booking_page' ) );
37
+ add_filter( 'woocommerce_currency_symbol', array( $this, 'filter_booking_currency_symbol' ) );
38
+ add_filter( 'get_booking_products_args', array( $this, 'filter_get_booking_products_args' ) );
39
+ add_filter( 'wcml_filter_currency_position', array( $this, 'create_booking_page_client_currency' ) );
40
+
41
+ add_filter( 'wcml_client_currency', array( $this, 'create_booking_page_client_currency' ) );
42
+
43
+ add_filter( 'wcml_custom_box_html', array( $this, 'custom_box_html'), 10, 3 );
44
+ add_filter( 'wcml_product_content_fields', array( $this, 'product_content_fields'), 10, 2 );
45
+ add_filter( 'wcml_product_content_fields_label', array( $this, 'product_content_fields_label'), 10, 2 );
46
+ add_filter( 'wcml_check_is_single', array( $this, 'show_custom_blocks_for_resources_and_persons'), 10, 3 );
47
+ add_filter( 'wcml_product_content_exception', array( $this, 'remove_custom_fields_to_translate' ), 10, 3 );
48
+ add_filter( 'wcml_product_content_label', array( $this, 'product_content_resource_label' ), 10, 2 );
49
+ add_action( 'wcml_update_extra_fields', array( $this, 'wcml_products_tab_sync_resources_and_persons'), 10, 3 );
50
+ }
51
+
52
+ function wcml_price_field_after_booking_base_cost( $post_id ){
53
+
54
+ $this->echo_wcml_price_field( $post_id, 'wcml_wc_booking_cost' );
55
+
56
+ }
57
+
58
+ function wcml_price_field_after_booking_block_cost( $post_id ){
59
+
60
+ $this->echo_wcml_price_field( $post_id, 'wcml_wc_booking_base_cost' );
61
+
62
+ }
63
+
64
+ function wcml_price_field_after_display_cost( $post_id ){
65
+
66
+ $this->echo_wcml_price_field( $post_id, 'wcml_wc_display_cost' );
67
+
68
+ }
69
+
70
+ function wcml_price_field_after_booking_pricing_base_cost( $pricing, $post_id ){
71
+
72
+ $this->echo_wcml_price_field( $post_id, 'wcml_wc_booking_pricing_base_cost', $pricing );
73
+
74
+ }
75
+
76
+ function wcml_price_field_after_booking_pricing_cost( $pricing, $post_id ){
77
+
78
+ $this->echo_wcml_price_field( $post_id, 'wcml_wc_booking_pricing_cost', $pricing );
79
+
80
+ }
81
+
82
+ function wcml_price_field_after_person_cost( $person_type_id ){
83
+
84
+ $this->echo_wcml_price_field( $person_type_id, 'wcml_wc_booking_person_cost', false, false );
85
+
86
+ }
87
+
88
+ function wcml_price_field_after_person_block_cost( $person_type_id ){
89
+
90
+ $this->echo_wcml_price_field( $person_type_id, 'wcml_wc_booking_person_block_cost', false, false );
91
+
92
+ }
93
+
94
+ function wcml_price_field_after_resource_cost( $resource_id, $post_id ){
95
+
96
+ $this->echo_wcml_price_field( $post_id, 'wcml_wc_booking_resource_cost', false, true, $resource_id );
97
+
98
+ }
99
+
100
+ function wcml_price_field_after_resource_block_cost( $resource_id, $post_id ){
101
+
102
+ $this->echo_wcml_price_field( $post_id, 'wcml_wc_booking_resource_block_cost', false, true, $resource_id );
103
+
104
+ }
105
+
106
+
107
+ function echo_wcml_price_field( $post_id, $field, $pricing = false, $check = true, $resource_id = false ){
108
+ global $woocommerce_wpml;
109
+
110
+ if( ( !$check || $woocommerce_wpml->products->is_original_product( $post_id ) ) && $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
111
+
112
+ $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
113
+
114
+ $wc_currencies = get_woocommerce_currencies();
115
+
116
+ echo '<div class="wcml_custom_cost_field" >';
117
+
118
+ foreach($currencies as $currency_code => $currency){
119
+
120
+ switch( $field ){
121
+ case 'wcml_wc_booking_cost':
122
+ woocommerce_wp_text_input( array( 'id' => 'wcml_wc_booking_cost', 'class'=>'wcml_bookings_custom_price', 'name' => 'wcml_wc_booking_cost['.$currency_code.']', 'label' => get_woocommerce_currency_symbol($currency_code), 'description' => __( 'One-off cost for the booking as a whole.', 'woocommerce-bookings' ), 'value' => get_post_meta( $post_id, '_wc_booking_cost_'.$currency_code, true ), 'type' => 'number', 'desc_tip' => true, 'custom_attributes' => array(
123
+ 'min' => '',
124
+ 'step' => '0.01'
125
+ ) ) );
126
+ break;
127
+ case 'wcml_wc_booking_base_cost':
128
+ woocommerce_wp_text_input( array( 'id' => 'wcml_wc_booking_base_cost', 'class'=>'wcml_bookings_custom_price', 'name' => 'wcml_wc_booking_base_cost['.$currency_code.']', 'label' => get_woocommerce_currency_symbol($currency_code), 'description' => __( 'This is the cost per block booked. All other costs (for resources and persons) are added to this.', 'woocommerce-bookings' ), 'value' => get_post_meta( $post_id, '_wc_booking_base_cost_'.$currency_code, true ), 'type' => 'number', 'desc_tip' => true, 'custom_attributes' => array(
129
+ 'min' => '',
130
+ 'step' => '0.01'
131
+ ) ) );
132
+ break;
133
+ case 'wcml_wc_display_cost':
134
+ woocommerce_wp_text_input( array( 'id' => 'wcml_wc_display_cost', 'class'=>'wcml_bookings_custom_price', 'name' => 'wcml_wc_display_cost['.$currency_code.']', 'label' => get_woocommerce_currency_symbol($currency_code), 'description' => __( 'The cost is displayed to the user on the frontend. Leave blank to have it calculated for you. If a booking has varying costs, this will be prefixed with the word "from:".', 'woocommerce-bookings' ), 'value' => get_post_meta( $post_id, '_wc_display_cost_'.$currency_code, true ), 'type' => 'number', 'desc_tip' => true, 'custom_attributes' => array(
135
+ 'min' => '',
136
+ 'step' => '0.01'
137
+ ) ) );
138
+ break;
139
+
140
+ case 'wcml_wc_booking_pricing_base_cost':
141
+
142
+ if( isset( $pricing[ 'base_cost_'.$currency_code ] ) ){
143
+ $value = $pricing[ 'base_cost_'.$currency_code ];
144
+ }else{
145
+ $value = '';
146
+ }
147
+
148
+ echo '<div class="wcml_bookings_range_block" >';
149
+ echo '<label>'. get_woocommerce_currency_symbol($currency_code) .'</label>';
150
+ echo '<input type="number" step="0.01" name="wcml_wc_booking_pricing_base_cost['.$currency_code.'][]" class="wcml_bookings_custom_price" value="'. $value .'" placeholder="0" />';
151
+ echo '</div>';
152
+ break;
153
+
154
+ case 'wcml_wc_booking_pricing_cost':
155
+
156
+ if( isset( $pricing[ 'cost_'.$currency_code ] ) ){
157
+ $value = $pricing[ 'cost_'.$currency_code ];
158
+ }else{
159
+ $value = '';
160
+ }
161
+
162
+ echo '<div class="wcml_bookings_range_block" >';
163
+ echo '<label>'. get_woocommerce_currency_symbol($currency_code) .'</label>';
164
+ echo '<input type="number" step="0.01" name="wcml_wc_booking_pricing_cost['.$currency_code.'][]" class="wcml_bookings_custom_price" value="'. $value .'" placeholder="0" />';
165
+ echo '</div>';
166
+ break;
167
+
168
+ case 'wcml_wc_booking_person_cost':
169
+
170
+ $value = get_post_meta( $post_id, 'cost_'.$currency_code, true );
171
+
172
+ echo '<div class="wcml_bookings_person_block" >';
173
+ echo '<label>'. get_woocommerce_currency_symbol($currency_code) .'</label>';
174
+ echo '<input type="number" step="0.01" name="wcml_wc_booking_person_cost['.$post_id.']['.$currency_code.']" class="wcml_bookings_custom_price" value="'. $value .'" placeholder="0" />';
175
+ echo '</div>';
176
+ break;
177
+
178
+ case 'wcml_wc_booking_person_block_cost':
179
+
180
+ $value = get_post_meta( $post_id, 'block_cost_'.$currency_code, true );
181
+
182
+ echo '<div class="wcml_bookings_person_block" >';
183
+ echo '<label>'. get_woocommerce_currency_symbol($currency_code) .'</label>';
184
+ echo '<input type="number" step="0.01" name="wcml_wc_booking_person_block_cost['.$post_id.']['.$currency_code.']" class="wcml_bookings_custom_price" value="'. $value .'" placeholder="0" />';
185
+ echo '</div>';
186
+ break;
187
+
188
+ case 'wcml_wc_booking_resource_cost':
189
+
190
+ $resource_base_costs = maybe_unserialize( get_post_meta( $post_id, '_resource_base_costs', true ) );
191
+
192
+ if( isset( $resource_base_costs[ 'custom_costs' ][ $currency_code ][ $resource_id ] ) ){
193
+ $value = $resource_base_costs[ 'custom_costs' ][ $currency_code ][ $resource_id ];
194
+ }else{
195
+ $value = '';
196
+ }
197
+
198
+ echo '<div class="wcml_bookings_resource_block" >';
199
+ echo '<label>'. get_woocommerce_currency_symbol($currency_code) .'</label>';
200
+ echo '<input type="number" step="0.01" name="wcml_wc_booking_resource_cost['.$resource_id.']['.$currency_code.']" class="wcml_bookings_custom_price" value="'. $value .'" placeholder="0" />';
201
+ echo '</div>';
202
+ break;
203
+
204
+ case 'wcml_wc_booking_resource_block_cost':
205
+
206
+ $resource_block_costs = maybe_unserialize( get_post_meta( $post_id, '_resource_block_costs', true ) );
207
+
208
+ if( isset( $resource_block_costs[ 'custom_costs' ][ $currency_code ][ $resource_id ] ) ){
209
+ $value = $resource_block_costs[ 'custom_costs' ][ $currency_code ][ $resource_id ];
210
+ }else{
211
+ $value = '';
212
+ }
213
+
214
+ echo '<div class="wcml_bookings_resource_block" >';
215
+ echo '<label>'. get_woocommerce_currency_symbol($currency_code) .'</label>';
216
+ echo '<input type="number" step="0.01" name="wcml_wc_booking_resource_block_cost['.$resource_id.']['.$currency_code.']" class="wcml_bookings_custom_price" value="'. $value .'" placeholder="0" />';
217
+ echo '</div>';
218
+ break;
219
+
220
+ default:
221
+ break;
222
+
223
+ }
224
+
225
+ }
226
+
227
+ echo '</div>';
228
+
229
+ }
230
+ }
231
+
232
+ function after_bookings_pricing( $post_id ){
233
+ global $woocommerce_wpml;
234
+
235
+ if( $woocommerce_wpml->products->is_original_product( $post_id ) && $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
236
+
237
+ $custom_costs_status = get_post_meta( $post_id, '_wcml_custom_costs_status', true );
238
+
239
+ $checked = !$custom_costs_status ? 'checked="checked"' : ' ';
240
+
241
+ echo '<div class="wcml_custom_costs">';
242
+
243
+ echo '<input type="radio" name="_wcml_custom_costs" id="wcml_custom_costs_auto" value="0" class="wcml_custom_costs_input" '. $checked .' />';
244
+ echo '<label for="wcml_custom_costs_auto">'. __('Calculate costs in other currencies automatically','wpml-wcml') .'</label>';
245
+
246
+ $checked = $custom_costs_status == 1 ? 'checked="checked"' : ' ';
247
+
248
+ echo '<input type="radio" name="_wcml_custom_costs" value="1" id="wcml_custom_costs_manually" class="wcml_custom_costs_input" '. $checked .' />';
249
+ echo '<label for="wcml_custom_costs_manually">'. __('Set costs in other currencies manually','wpml-wcml') .'</label>';
250
+
251
+ wp_nonce_field( 'wcml_save_custom_costs', '_wcml_custom_costs_nonce' );
252
+
253
+ echo '</div>';
254
+ }
255
+
256
+ }
257
+
258
+ function save_custom_costs( $post_id, $post ){
259
+ global $woocommerce_wpml;
260
+
261
+ $nonce = filter_input( INPUT_POST, '_wcml_custom_costs_nonce', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
262
+
263
+ if( isset( $_POST['_wcml_custom_costs'] ) && isset( $nonce ) && wp_verify_nonce( $nonce, 'wcml_save_custom_costs' ) ){
264
+
265
+ update_post_meta( $post_id, '_wcml_custom_costs_status', $_POST['_wcml_custom_costs'] );
266
+
267
+ if( $_POST['_wcml_custom_costs'] == 1 ){
268
+
269
+ $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
270
+
271
+ foreach( $currencies as $code => $currency ){
272
+
273
+ $wc_booking_cost = $_POST[ 'wcml_wc_booking_cost' ][ $code ];
274
+ update_post_meta( $post_id, '_wc_booking_cost_'.$code, $wc_booking_cost );
275
+
276
+ $wc_booking_base_cost = $_POST[ 'wcml_wc_booking_base_cost' ][ $code ];
277
+ update_post_meta( $post_id, '_wc_booking_base_cost_'.$code, $wc_booking_base_cost );
278
+
279
+ $wc_display_cost = $_POST[ 'wcml_wc_display_cost' ][ $code ];
280
+ update_post_meta( $post_id, '_wc_display_cost_'.$code, $wc_display_cost );
281
+
282
+ }
283
+
284
+ //person costs
285
+ if( isset( $_POST[ 'wcml_wc_booking_person_cost' ] ) ) {
286
+
287
+ foreach ($_POST['wcml_wc_booking_person_cost'] as $person_id => $costs) {
288
+
289
+ foreach ($currencies as $code => $currency) {
290
+
291
+ $wc_booking_person_cost = $costs[$code];
292
+ update_post_meta($person_id, 'cost_' . $code, $wc_booking_person_cost);
293
+
294
+ }
295
+
296
+ }
297
+
298
+ }
299
+
300
+ if( isset( $_POST[ 'wcml_wc_booking_person_cost' ] ) ){
301
+
302
+ foreach( $_POST[ 'wcml_wc_booking_person_block_cost' ] as $person_id => $costs ){
303
+
304
+ foreach( $currencies as $code => $currency ){
305
+
306
+ $wc_booking_person_block_cost = $costs[ $code ];
307
+ update_post_meta( $person_id, 'block_cost_'.$code, $wc_booking_person_block_cost );
308
+
309
+ }
310
+
311
+ }
312
+
313
+ }
314
+
315
+ }
316
+ }
317
+
318
+
319
+
320
+ }
321
+
322
+ function sync_booking_data( $original_product_id, $current_product_id ){
323
+
324
+ if( has_term( 'booking', 'product_type', $original_product_id ) ){
325
+ global $wpdb, $sitepress, $pagenow, $iclTranslationManagement;
326
+
327
+ // get language code
328
+ $language_details = $sitepress->get_element_language_details( $original_product_id, 'post_product' );
329
+ if ( $pagenow == 'admin.php' && empty( $language_details ) ) {
330
+ //translation editor support: sidestep icl_translations_cache
331
+ $language_details = $wpdb->get_row( $wpdb->prepare( "SELECT element_id, trid, language_code, source_language_code FROM {$wpdb->prefix}icl_translations WHERE element_id = %d AND element_type = 'post_product'", $original_product_id ) );
332
+ }
333
+ if ( empty( $language_details ) ) {
334
+ return;
335
+ }
336
+
337
+ // pick posts to sync
338
+ $posts = array();
339
+ $translations = $sitepress->get_element_translations( $language_details->trid, 'post_product' );
340
+ foreach ( $translations as $translation ) {
341
+
342
+ if ( !$translation->original ) {
343
+ $posts[ $translation->element_id ] = $translation;
344
+ }
345
+ }
346
+
347
+ foreach ( $posts as $post_id => $translation ) {
348
+
349
+ $trn_lang = $sitepress->get_language_for_element( $post_id, 'post_product' );
350
+
351
+ //sync_resources
352
+ $this->sync_resources( $original_product_id, $post_id, $trn_lang );
353
+
354
+ //sync_persons
355
+ $this->sync_persons( $original_product_id, $post_id, $trn_lang );
356
+ }
357
+
358
+ }
359
+
360
+ }
361
+
362
+ function sync_resources( $original_product_id, $trnsl_product_id, $lang_code, $duplicate = true ){
363
+ global $wpdb;
364
+
365
+ $orig_resources = $wpdb->get_results( $wpdb->prepare( "SELECT resource_id, sort_order FROM {$wpdb->prefix}wc_booking_relationships WHERE product_id = %d", $original_product_id ) );
366
+
367
+ $trnsl_product_resources = $wpdb->get_col( $wpdb->prepare( "SELECT resource_id FROM {$wpdb->prefix}wc_booking_relationships WHERE product_id = %d", $trnsl_product_id ) );
368
+
369
+ foreach ($orig_resources as $resource) {
370
+
371
+ $trns_resource_id = icl_object_id( $resource->resource_id, 'bookable_resource', false, $lang_code );
372
+
373
+ if ( !is_null( $trns_resource_id ) && in_array( $trns_resource_id, $trnsl_product_resources ) ) {
374
+
375
+ if ( ( $key = array_search( $trns_resource_id, $trnsl_product_resources ) ) !== false ) {
376
+
377
+ unset($trnsl_product_resources[$key]);
378
+
379
+ $wpdb->update(
380
+ $wpdb->prefix . 'wc_booking_relationships',
381
+ array(
382
+ 'sort_order' => $resource->sort_order
383
+ ),
384
+ array(
385
+ 'product_id' => $trnsl_product_id,
386
+ 'resource_id' => $trns_resource_id
387
+ )
388
+ );
389
+
390
+ update_post_meta( $trns_resource_id, 'qty', get_post_meta( $resource->resource_id, 'qty', true ) );
391
+ update_post_meta( $trns_resource_id, '_wc_booking_availability', get_post_meta( $resource->resource_id, '_wc_booking_availability', true ) );
392
+
393
+ }
394
+
395
+ } else {
396
+
397
+ if( $duplicate ){
398
+
399
+ $trns_resource_id = $this->duplicate_resource( $trnsl_product_id, $resource, $lang_code );
400
+
401
+ }else{
402
+
403
+ continue;
404
+
405
+ }
406
+
407
+
408
+ }
409
+
410
+ }
411
+
412
+ foreach ($trnsl_product_resources as $trnsl_product_resource) {
413
+
414
+ $wpdb->delete(
415
+ $wpdb->prefix . 'wc_booking_relationships',
416
+ array(
417
+ 'product_id' => $trnsl_product_id,
418
+ 'resource_id' => $trnsl_product_resource
419
+ )
420
+ );
421
+
422
+ wp_delete_post( $trnsl_product_resource );
423
+
424
+ }
425
+
426
+ }
427
+
428
+
429
+ function duplicate_resource( $tr_product_id, $resource, $lang_code){
430
+ global $sitepress, $wpdb, $iclTranslationManagement;
431
+
432
+ if( method_exists( $sitepress, 'make_duplicate' ) ){
433
+
434
+ $trns_resource_id = $sitepress->make_duplicate( $resource->resource_id, $lang_code );
435
+
436
+ }else{
437
+
438
+ if ( !isset( $iclTranslationManagement ) ) {
439
+ $iclTranslationManagement = new TranslationManagement;
440
+ }
441
+
442
+ $trns_resource_id = $iclTranslationManagement->make_duplicate( $resource->resource_id, $lang_code );
443
+
444
+ }
445
+
446
+ $wpdb->insert(
447
+ $wpdb->prefix . 'wc_booking_relationships',
448
+ array(
449
+ 'product_id' => $tr_product_id,
450
+ 'resource_id' => $trns_resource_id,
451
+ 'sort_order' => $resource->sort_order
452
+ )
453
+ );
454
+
455
+ delete_post_meta( $trns_resource_id, '_icl_lang_duplicate_of' );
456
+
457
+ return $trns_resource_id;
458
+ }
459
+
460
+ function sync_persons( $original_product_id, $tr_product_id, $lang_code, $duplicate = true ){
461
+ global $wpdb, $woocommerce_wpml;
462
+
463
+ $orig_persons = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'bookable_person'", $original_product_id ) );
464
+
465
+ $trnsl_persons = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'bookable_person'", $tr_product_id ) );
466
+
467
+
468
+ foreach ($orig_persons as $person) {
469
+
470
+ $trnsl_person_id = icl_object_id( $person, 'bookable_person', false, $lang_code );
471
+
472
+ if ( !is_null( $trnsl_person_id ) && in_array( $trnsl_person_id, $trnsl_persons ) ) {
473
+
474
+ if ( ( $key = array_search( $trnsl_person_id, $trnsl_persons ) ) !== false ) {
475
+
476
+ unset($trnsl_persons[$key]);
477
+
478
+ update_post_meta( $trnsl_person_id, 'block_cost', get_post_meta( $person, 'block_cost', true ) );
479
+ update_post_meta( $trnsl_person_id, 'cost', get_post_meta( $person, 'cost', true ) );
480
+ update_post_meta( $trnsl_person_id, 'max', get_post_meta( $person, 'max', true ) );
481
+ update_post_meta( $trnsl_person_id, 'min', get_post_meta( $person, 'min', true ) );
482
+
483
+
484
+ if( get_post_meta( $person, '_wcml_custom_costs_status', true ) && $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT){
485
+ $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
486
+
487
+ foreach( $currencies as $code => $currency ){
488
+
489
+ update_post_meta( $trnsl_person_id, 'block_cost_'.$code, get_post_meta( $person, 'block_cost_'.$code, true ) );
490
+ update_post_meta( $trnsl_person_id, 'block_cost_'.$code, get_post_meta( $person, 'cost_'.$code, true ) );
491
+
492
+ }
493
+ }
494
+
495
+ }
496
+
497
+ }else{
498
+
499
+ if( $duplicate ) {
500
+
501
+ $this->duplicate_person($tr_product_id, $person, $lang_code);
502
+
503
+ }else{
504
+
505
+ continue;
506
+
507
+ }
508
+
509
+ }
510
+
511
+ }
512
+
513
+ foreach ($trnsl_persons as $trnsl_persons) {
514
+
515
+ wp_delete_post( $trnsl_persons );
516
+
517
+ }
518
+
519
+ }
520
+
521
+
522
+ function duplicate_person( $tr_product_id, $person_id, $lang_code ){
523
+ global $sitepress, $wpdb, $iclTranslationManagement;
524
+
525
+ if( method_exists( $sitepress, 'make_duplicate' ) ){
526
+
527
+ $new_person_id = $sitepress->make_duplicate( $person_id, $lang_code );
528
+
529
+ }else{
530
+
531
+ if ( !isset( $iclTranslationManagement ) ) {
532
+ $iclTranslationManagement = new TranslationManagement;
533
+ }
534
+
535
+ $new_person_id = $iclTranslationManagement->make_duplicate( $person_id, $lang_code );
536
+
537
+ }
538
+
539
+ $wpdb->update(
540
+ $wpdb->posts,
541
+ array(
542
+ 'post_parent' => $tr_product_id
543
+ ),
544
+ array(
545
+ 'ID' => $new_person_id
546
+ )
547
+ );
548
+
549
+ delete_post_meta( $new_person_id, '_icl_lang_duplicate_of' );
550
+
551
+ return $new_person_id;
552
+ }
553
+
554
+ function filter_wc_booking_cost( $check, $object_id, $meta_key, $single ){
555
+
556
+ if( in_array( $meta_key, array( '_wc_booking_cost', '_wc_booking_base_cost', '_wc_display_cost', '_wc_booking_pricing', 'cost', 'block_cost', '_resource_base_costs', '_resource_block_costs' ) ) ){
557
+
558
+ global $woocommerce_wpml;
559
+
560
+ if( $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
561
+
562
+ $original_id = icl_object_id( $object_id, 'product', true, $woocommerce_wpml->products->get_original_product_language( $object_id ) );
563
+
564
+ $cost_status = get_post_meta( $original_id, '_wcml_custom_costs_status', true );
565
+
566
+ $currency = $woocommerce_wpml->multi_currency_support->get_client_currency();
567
+
568
+ if ( $currency == get_option('woocommerce_currency') ){
569
+ return $check;
570
+ }
571
+
572
+ if( in_array( $meta_key, array( 'cost', 'block_cost' ) ) ) {
573
+
574
+ if ( get_post_type($object_id) == 'bookable_person' ) {
575
+
576
+ $value = get_post_meta($object_id, $meta_key . '_' . $currency, true);
577
+
578
+ if ( $cost_status && $value ) {
579
+
580
+ return $value;
581
+
582
+ } else {
583
+
584
+ remove_filter( 'get_post_metadata', array( $this, 'filter_wc_booking_cost' ), 10, 4 );
585
+
586
+ $cost = get_post_meta( $object_id, $meta_key, true);
587
+
588
+ add_filter( 'get_post_metadata', array( $this, 'filter_wc_booking_cost' ), 10, 4 );
589
+
590
+ return $woocommerce_wpml->multi_currency->convert_price_amount( $cost, $currency );
591
+ }
592
+
593
+ } else {
594
+
595
+ return $check;
596
+
597
+ }
598
+
599
+ }
600
+
601
+ if( in_array ( $meta_key, array( '_wc_booking_pricing', '_resource_base_costs', '_resource_block_costs' ) ) ){
602
+
603
+ remove_filter( 'get_post_metadata', array( $this, 'filter_wc_booking_cost' ), 10, 4 );
604
+
605
+ if( $meta_key == '_wc_booking_pricing' ){
606
+
607
+ if( $original_id != $object_id ){
608
+ $value = get_post_meta( $original_id, $meta_key );
609
+ }else{
610
+ $value = $check;
611
+ }
612
+
613
+ }else{
614
+
615
+ $costs = maybe_unserialize( get_post_meta( $object_id, $meta_key, true ) );
616
+
617
+ if( !$costs ){
618
+ $value = $check;
619
+ }elseif( $cost_status && isset( $costs[ 'custom_costs' ][ $currency ] ) ){
620
+ $value = array( 0 => $costs[ 'custom_costs' ][ $currency ] );
621
+ }elseif( $cost_status && isset( $costs[ 0 ][ 'custom_costs' ][ $currency ] )){
622
+ $value = array( 0 => $costs[ 0 ][ 'custom_costs' ][ $currency ] );
623
+ }else{
624
+
625
+ $converted_values = array();
626
+
627
+ foreach( $costs as $resource_id => $cost ){
628
+ $converted_values[0][ $resource_id ] = $woocommerce_wpml->multi_currency->convert_price_amount( $cost, $currency );
629
+ }
630
+
631
+ $value = $converted_values;
632
+ }
633
+
634
+ }
635
+
636
+ add_filter( 'get_post_metadata', array( $this, 'filter_wc_booking_cost' ), 10, 4 );
637
+
638
+ return $value;
639
+
640
+ }
641
+
642
+ $value = get_post_meta( $original_id, $meta_key.'_'.$currency, true );
643
+
644
+ if( $cost_status && ( !empty($value) || ( empty($value) && $meta_key == '_wc_display_cost' ) ) ){
645
+
646
+ return $value;
647
+
648
+ }else{
649
+
650
+ remove_filter( 'get_post_metadata', array( $this, 'filter_wc_booking_cost' ), 10, 4 );
651
+
652
+ $value = get_post_meta( $original_id, $meta_key, true );
653
+
654
+ $value = $woocommerce_wpml->multi_currency->convert_price_amount( $value, $currency );
655
+
656
+ add_filter( 'get_post_metadata', array( $this, 'filter_wc_booking_cost' ), 10, 4 );
657
+
658
+ return $value;
659
+
660
+ }
661
+
662
+ }
663
+
664
+ }
665
+
666
+ return $check;
667
+ }
668
+
669
+ function update_wc_booking_costs( $check, $object_id, $meta_key, $meta_value, $prev_value ){
670
+
671
+ if( in_array( $meta_key, array( '_wc_booking_pricing', '_resource_base_costs', '_resource_block_costs' ) ) ){
672
+
673
+ global $woocommerce_wpml;
674
+
675
+ remove_filter( 'update_post_metadata', array( $this, 'update_wc_booking_costs' ), 10, 5 );
676
+
677
+ $nonce = filter_input( INPUT_POST, '_wcml_custom_costs_nonce', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
678
+
679
+ if( isset( $_POST['_wcml_custom_costs'] ) && isset( $nonce ) && wp_verify_nonce( $nonce, 'wcml_save_custom_costs' ) && $_POST['_wcml_custom_costs'] == 1 ) {
680
+
681
+ $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
682
+
683
+ $updated_meta = array();
684
+
685
+ if( $meta_key == '_wc_booking_pricing' ){
686
+
687
+ foreach (maybe_unserialize($meta_value) as $key => $prices) {
688
+
689
+ $updated_meta[ $key ] = $prices;
690
+
691
+ foreach ($currencies as $code => $currency) {
692
+
693
+ $updated_meta[ $key ][ 'base_cost_'.$code ] = $_POST[ 'wcml_wc_booking_pricing_base_cost' ][ $code ][ $key ];
694
+ $updated_meta[ $key ][ 'cost_'.$code ] = $_POST[ 'wcml_wc_booking_pricing_cost' ][ $code ][ $key ];
695
+
696
+ }
697
+
698
+ }
699
+
700
+ update_post_meta( $object_id, '_wc_booking_pricing', $updated_meta );
701
+
702
+ }elseif( $meta_key == '_resource_base_costs' ){
703
+
704
+ if( isset( $_POST[ 'wcml_wc_booking_resource_cost' ] ) ) {
705
+
706
+ $updated_meta = $meta_value;
707
+
708
+ $wc_booking_resource_costs = array();
709
+
710
+ foreach ( $_POST['wcml_wc_booking_resource_cost'] as $resource_id => $costs) {
711
+
712
+ foreach ($currencies as $code => $currency) {
713
+
714
+ $wc_booking_resource_costs[ $code ][ $resource_id ] = $costs[ $code ];
715
+
716
+ }
717
+
718
+ }
719
+
720
+ $updated_meta[ 'custom_costs' ] = $wc_booking_resource_costs;
721
+
722
+ update_post_meta( $object_id, '_resource_base_costs', $updated_meta );
723
+
724
+ $this->sync_resource_costs_with_translations( $object_id, $meta_key );
725
+
726
+ }
727
+
728
+ }elseif( $meta_key == '_resource_block_costs' ){
729
+
730
+ if( isset( $_POST[ 'wcml_wc_booking_resource_block_cost' ] ) ){
731
+
732
+ $updated_meta = $meta_value;
733
+
734
+ $wc_booking_resource_block_costs = array();
735
+
736
+ foreach( $_POST[ 'wcml_wc_booking_resource_block_cost' ] as $resource_id => $costs ){
737
+
738
+ foreach( $currencies as $code => $currency ){
739
+
740
+ $wc_booking_resource_block_costs[ $code ][ $resource_id ] = $costs[ $code ];
741
+
742
+ }
743
+
744
+ }
745
+
746
+ $updated_meta[ 'custom_costs' ] = $wc_booking_resource_block_costs;
747
+
748
+ update_post_meta( $object_id, '_resource_block_costs', $updated_meta );
749
+
750
+ $this->sync_resource_costs_with_translations( $object_id, $meta_key );
751
+
752
+ }
753
+
754
+ }
755
+
756
+ add_filter( 'update_post_metadata', array( $this, 'update_wc_booking_costs' ), 10, 5 );
757
+
758
+ return true;
759
+
760
+ }elseif(in_array( $meta_key, array( '_resource_base_costs', '_resource_block_costs' ) ) ){
761
+
762
+ $return = $this->sync_resource_costs_with_translations( $object_id, $meta_key, $check );
763
+
764
+ add_filter( 'update_post_metadata', array( $this, 'update_wc_booking_costs' ), 10, 5 );
765
+
766
+ return $return;
767
+
768
+ }else{
769
+
770
+ add_filter( 'update_post_metadata', array( $this, 'update_wc_booking_costs' ), 10, 5 );
771
+
772
+ return $check;
773
+
774
+ }
775
+
776
+ }else{
777
+
778
+ return $check;
779
+
780
+ }
781
+
782
+ }
783
+
784
+ function sync_resource_costs_with_translations( $object_id, $meta_key, $check = false ){
785
+ global $sitepress,$woocommerce_wpml;
786
+
787
+ $original_product_id = icl_object_id( $object_id, 'product', true, $woocommerce_wpml->products->get_original_product_language( $object_id ) );
788
+
789
+ if( $object_id == $original_product_id ){
790
+
791
+ $trid = $sitepress->get_element_trid( $object_id, 'post_product' );
792
+ $translations = $sitepress->get_element_translations( $trid, 'post_product' );
793
+
794
+ foreach ( $translations as $translation ) {
795
+
796
+ if ( !$translation->original ) {
797
+
798
+ $this->sync_resource_costs( $original_product_id, $translation->element_id, $meta_key, $translation->language_code );
799
+
800
+ }
801
+ }
802
+
803
+ return $check;
804
+
805
+ }else{
806
+
807
+ $language_code = $sitepress->get_language_for_element( $object_id, 'post_product' );
808
+
809
+ $this->sync_resource_costs( $original_product_id, $object_id, $meta_key, $language_code );
810
+
811
+ return true;
812
+
813
+ }
814
+
815
+ }
816
+
817
+ function sync_resource_costs( $original_product_id, $object_id, $meta_key, $language_code ){
818
+
819
+ $original_costs = maybe_unserialize( get_post_meta( $original_product_id, $meta_key, true ) );
820
+
821
+ $wc_booking_resource_costs = array();
822
+
823
+ foreach ( $original_costs as $resource_id => $costs ) {
824
+
825
+ if ( $resource_id == 'custom_costs' && isset($costs[ 'custom_costs']) ){
826
+
827
+ foreach ( $costs[ 'custom_costs'] as $code => $currencies ) {
828
+
829
+ foreach( $currencies as $custom_costs_resource_id => $custom_cost ){
830
+
831
+ $trns_resource_id = icl_object_id( $custom_costs_resource_id, 'bookable_resource', true, $language_code );
832
+
833
+ $wc_booking_resource_costs[ 'custom_costs' ][ $code ][ $trns_resource_id ] = $custom_cost;
834
+
835
+ }
836
+
837
+ }
838
+
839
+ }else{
840
+
841
+ $trns_resource_id = icl_object_id( $resource_id, 'bookable_resource', true, $language_code );
842
+
843
+ $wc_booking_resource_costs[ $trns_resource_id ] = $costs;
844
+
845
+ }
846
+
847
+ }
848
+
849
+ update_post_meta( $object_id, $meta_key, $wc_booking_resource_costs );
850
+
851
+ }
852
+
853
+
854
+ function wc_bookings_process_cost_rules_cost( $cost, $fields, $key ){
855
+ return $this->filter_pricing_cost( $cost, $fields, 'cost_', $key );
856
+ }
857
+
858
+ function wc_bookings_process_cost_rules_base_cost( $base_cost, $fields, $key ){
859
+ return $this->filter_pricing_cost( $base_cost, $fields, 'base_cost_', $key );
860
+ }
861
+
862
+ function filter_pricing_cost( $cost, $fields, $name, $key ){
863
+ global $woocommerce_wpml, $product;
864
+
865
+ if( $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
866
+
867
+ $currency = $woocommerce_wpml->multi_currency_support->get_client_currency();
868
+
869
+ if ( $currency == get_option('woocommerce_currency') ) {
870
+ return $cost;
871
+ }
872
+
873
+ if( isset( $_POST[ 'form' ] ) ){
874
+ parse_str( $_POST[ 'form' ], $posted );
875
+
876
+ $booking_id = $posted[ 'add-to-cart' ];
877
+
878
+ }elseif( isset( $_POST[ 'add-to-cart' ] ) ){
879
+
880
+ $booking_id = $_POST[ 'add-to-cart' ];
881
+
882
+ }
883
+
884
+ if( isset( $booking_id ) ){
885
+ $original_id = icl_object_id( $booking_id, 'product', true, $woocommerce_wpml->products->get_original_product_language( $booking_id ) );
886
+
887
+ if( $booking_id != $original_id ){
888
+ $fields = maybe_unserialize( get_post_meta( $original_id, '_wc_booking_pricing', true ) );
889
+ $fields = $fields[$key];
890
+ }
891
+ }
892
+
893
+ if( isset( $fields[ $name.$currency ] ) ){
894
+ return $fields[ $name.$currency ];
895
+ }else{
896
+ return $woocommerce_wpml->multi_currency->convert_price_amount( $cost, $currency );
897
+ }
898
+
899
+ }
900
+
901
+ return $cost;
902
+
903
+ }
904
+
905
+ function load_assets( ){
906
+ global $pagenow, $woocommerce_wpml;
907
+
908
+ if( $pagenow == 'post.php' || $pagenow == 'post-new.php' ){
909
+
910
+ wp_register_style( 'wcml-bookings-css', WCML_PLUGIN_URL . '/compatibility/assets/css/wcml-bookings.css', array(), WCML_VERSION );
911
+ wp_enqueue_style( 'wcml-bookings-css' );
912
+
913
+ wp_register_script( 'wcml-bookings-js' , WCML_PLUGIN_URL . '/compatibility/assets/js/wcml-bookings.js', array('jquery'), WCML_VERSION);
914
+ wp_enqueue_script( 'wcml-bookings-js' );
915
+ wp_localize_script( 'wcml-bookings-js', 'lock_fields', ( isset( $_GET[ 'post' ] ) && get_post_type( $_GET[ 'post' ] ) == 'product' && !$woocommerce_wpml->products->is_original_product( $_GET[ 'post' ] ) ) ||
916
+ ( $pagenow == 'post-new.php' && isset( $_GET[ 'source_lang' ] ) ) ? 1 : false );
917
+ }
918
+
919
+ }
920
+
921
+
922
+ function wcml_multi_currency_is_ajax( $actions ){
923
+
924
+ $actions[] = 'wc_bookings_calculate_costs';
925
+
926
+ return $actions;
927
+ }
928
+
929
+ function filter_bundled_product_in_cart_contents( $cart_item, $key, $current_language ){
930
+
931
+ if( $cart_item[ 'data' ] instanceof WC_Product_Booking ){
932
+ global $woocommerce_wpml;
933
+
934
+ $current_id = icl_object_id( $cart_item[ 'data' ]->id, 'product', true, $current_language );
935
+ $cart_product_id = $cart_item['data']->id;
936
+
937
+ if( $current_id != $cart_product_id ) {
938
+
939
+ $cart_item['data'] = new WC_Product_Booking( $current_id );
940
+
941
+ }
942
+
943
+ if( $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT || $current_id != $cart_product_id ){
944
+
945
+ $booking_info = array(
946
+ 'wc_bookings_field_start_date_year' => $cart_item[ 'booking' ][ '_year' ],
947
+ 'wc_bookings_field_start_date_month' => $cart_item[ 'booking' ][ '_month' ],
948
+ 'wc_bookings_field_start_date_day' => $cart_item[ 'booking' ][ '_day' ],
949
+ 'add-to-cart' => $current_id,
950
+ '_persons' => isset( $cart_item[ 'booking' ][ '_persons' ] ) ? isset( $cart_item[ 'booking' ][ '_persons' ] ) : array()
951
+ );
952
+
953
+ if( isset( $cart_item[ 'booking' ][ '_resource_id' ] ) ){
954
+ $booking_info[ 'wc_bookings_field_resource' ] = $cart_item[ 'booking' ][ '_resource_id' ];
955
+ }
956
+
957
+ if( isset( $cart_item[ 'booking' ][ '_duration' ] ) ){
958
+ $booking_info[ 'wc_bookings_field_duration' ] = $cart_item[ 'booking' ][ '_duration' ];
959
+ }
960
+
961
+ if( isset( $cart_item[ 'booking' ][ '_time' ] ) ){
962
+ $booking_info[ 'wc_bookings_field_start_date_time' ] = $cart_item[ 'booking' ][ '_time' ];
963
+ }
964
+
965
+ $booking_form = new WC_Booking_Form( wc_get_product( $current_id ) );
966
+
967
+ $prod_qty = get_post_meta( $current_id, '_wc_booking_qty', true );
968
+ update_post_meta( $current_id, '_wc_booking_qty', intval( $prod_qty + $cart_item[ 'booking' ][ '_qty' ] ) );
969
+ $cost = $booking_form->calculate_booking_cost( $booking_info );
970
+ update_post_meta( $current_id, '_wc_booking_qty', $prod_qty );
971
+
972
+ if( !is_wp_error( $cost ) ){
973
+ $cart_item[ 'data' ]->set_price( $cost );
974
+ }
975
+ }
976
+
977
+ }
978
+
979
+ return $cart_item;
980
+
981
+ }
982
+
983
+ function booking_currency_dropdown(){
984
+ global $woocommerce_wpml, $sitepress;
985
+
986
+ if( $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
987
+ $current_booking_currency = $this->get_cookie_booking_currency();
988
+
989
+ $wc_currencies = get_woocommerce_currencies();
990
+ $order_currencies = $woocommerce_wpml->multi_currency->get_orders_currencies();
991
+ ?>
992
+ <tr valign="top">
993
+ <th scope="row"><?php _e( 'Booking currency', 'wpml-wcml' ); ?></th>
994
+ <td>
995
+ <select id="dropdown_booking_currency">
996
+
997
+ <?php foreach($order_currencies as $currency => $count ): ?>
998
+
999
+ <option value="<?php echo $currency ?>" <?php echo $current_booking_currency == $currency ? 'selected="selected"':''; ?>><?php echo $wc_currencies[$currency]; ?></option>
1000
+
1001
+ <?php endforeach; ?>
1002
+
1003
+ </select>
1004
+ </td>
1005
+ </tr>
1006
+
1007
+ <?php
1008
+
1009
+ $wcml_booking_set_currency_nonce = wp_create_nonce( 'booking_set_currency' );
1010
+
1011
+ wc_enqueue_js( "
1012
+
1013
+ jQuery(document).on('change', '#dropdown_booking_currency', function(){
1014
+ jQuery.ajax({
1015
+ url: ajaxurl,
1016
+ type: 'post',
1017
+ data: {
1018
+ action: 'wcml_booking_set_currency',
1019
+ currency: jQuery('#dropdown_booking_currency').val(),
1020
+ wcml_nonce: '".$wcml_booking_set_currency_nonce."'
1021
+ },
1022
+ success: function( response ){
1023
+ if(typeof response.error !== 'undefined'){
1024
+ alert(response.error);
1025
+ }else{
1026
+ window.location = window.location.href;
1027
+ }
1028
+ }
1029
+ })
1030
+ });
1031
+ ");
1032
+
1033
+ }
1034
+
1035
+ }
1036
+
1037
+ function set_booking_currency_ajax(){
1038
+
1039
+ $nonce = filter_input( INPUT_POST, 'wcml_nonce', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
1040
+ if(!$nonce || !wp_verify_nonce($nonce, 'booking_set_currency')){
1041
+ echo json_encode(array('error' => __('Invalid nonce', 'wpml-wcml')));
1042
+ die();
1043
+ }
1044
+
1045
+ $this->set_booking_currency(filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_FULL_SPECIAL_CHARS ));
1046
+
1047
+ die();
1048
+ }
1049
+
1050
+ function set_booking_currency( $currency_code = false ){
1051
+
1052
+ if( !isset( $_COOKIE [ '_wcml_booking_currency' ]) && !headers_sent()) {
1053
+ global $woocommerce_wpml;
1054
+
1055
+ $currency_code = get_woocommerce_currency();
1056
+
1057
+ if ( $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
1058
+ $order_currencies = $woocommerce_wpml->multi_currency->get_orders_currencies();
1059
+
1060
+ if (!isset($order_currencies[$currency_code])) {
1061
+ foreach ($order_currencies as $currency_code => $count) {
1062
+ $currency_code = $currency_code;
1063
+ break;
1064
+ }
1065
+ }
1066
+ }
1067
+ }
1068
+
1069
+ if( $currency_code ){
1070
+ setcookie('_wcml_booking_currency', $currency_code , time() + 86400, COOKIEPATH, COOKIE_DOMAIN);
1071
+ }
1072
+
1073
+ }
1074
+
1075
+ function get_cookie_booking_currency(){
1076
+
1077
+ if( isset( $_COOKIE [ '_wcml_booking_currency' ] ) ){
1078
+ $currency = $_COOKIE[ '_wcml_booking_currency' ];
1079
+ }else{
1080
+ $currency = get_woocommerce_currency();
1081
+ }
1082
+
1083
+ return $currency;
1084
+ }
1085
+
1086
+ function filter_booking_currency_symbol( $currency ){
1087
+ global $pagenow;
1088
+
1089
+ remove_filter( 'woocommerce_currency_symbol', array( $this, 'filter_booking_currency_symbol' ) );
1090
+ if( isset( $_COOKIE [ '_wcml_booking_currency' ] ) && $pagenow == 'edit.php' && isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'create_booking' ){
1091
+ $currency = get_woocommerce_currency_symbol( $_COOKIE [ '_wcml_booking_currency' ] );
1092
+ }
1093
+ add_filter( 'woocommerce_currency_symbol', array( $this, 'filter_booking_currency_symbol' ) );
1094
+
1095
+ return $currency;
1096
+ }
1097
+
1098
+ function create_booking_page_client_currency( $currency ){
1099
+ global $pagenow;
1100
+
1101
+ if( wpml_is_ajax() && isset( $_POST[ 'form' ] ) ){
1102
+ parse_str( $_POST[ 'form' ], $posted );
1103
+ }
1104
+
1105
+ if( ( $pagenow == 'edit.php' && isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'create_booking' ) || ( isset( $posted[ '_wp_http_referer' ] ) && strpos( $posted[ '_wp_http_referer' ], 'page=create_booking' ) !== false ) ){
1106
+ $currency = $this->get_cookie_booking_currency();
1107
+ }
1108
+
1109
+ return $currency;
1110
+ }
1111
+
1112
+ function set_order_currency_on_create_booking_page( $order_id ){
1113
+ global $sitepress;
1114
+
1115
+ update_post_meta( $order_id, '_order_currency', $this->get_cookie_booking_currency() );
1116
+
1117
+ update_post_meta( $order_id, 'wpml_language', $sitepress->get_current_language() );
1118
+
1119
+ }
1120
+
1121
+ function filter_get_booking_products_args( $args ){
1122
+ if( isset( $args['suppress_filters'] ) ){
1123
+ $args['suppress_filters'] = false;
1124
+ }
1125
+ return $args;
1126
+ }
1127
+
1128
+ function custom_box_html( $html, $template_data, $lang ){
1129
+
1130
+ if( in_array( $template_data[ 'product_content' ], array( 'wc_booking_resources', 'wc_booking_persons' ) ) ){
1131
+
1132
+ switch( $template_data[ 'product_content' ] ){
1133
+ case 'wc_booking_resources':
1134
+
1135
+ $resources = array();
1136
+
1137
+ foreach( maybe_unserialize( get_post_meta( $template_data[ 'product_id' ], '_resource_base_costs', true ) ) as $resource_id => $cost ){
1138
+
1139
+ if( $resource_id == 'custom_costs' ) continue;
1140
+
1141
+ $trns_resource_id = icl_object_id( $resource_id, 'bookable_resource', false, $template_data[ 'lang' ] );
1142
+
1143
+ if( !empty( $trns_resource_id ) && $template_data[ 'translation_exist' ] ){
1144
+ $resources[ $resource_id ] = $trns_resource_id;
1145
+ }else{
1146
+ $resources[ $resource_id ] = false;
1147
+ }
1148
+
1149
+ }
1150
+ $template_data[ 'resources' ] = $resources;
1151
+
1152
+ break;
1153
+ case 'wc_booking_persons':
1154
+ global $wpdb;
1155
+
1156
+ $persons = array();
1157
+
1158
+ $original_persons = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'bookable_person' AND post_status = 'publish'", $template_data[ 'product_id' ] ) );
1159
+
1160
+ foreach( $original_persons as $person ){
1161
+
1162
+ $trnsl_person_id = icl_object_id( $person, 'bookable_person', false, $template_data[ 'lang' ] );
1163
+
1164
+ if( !empty( $trnsl_person_id ) && $template_data[ 'translation_exist' ] ){
1165
+ $persons[ $person ] = $trnsl_person_id;
1166
+ }else{
1167
+ $persons[ $person ] = false;
1168
+ }
1169
+
1170
+ }
1171
+
1172
+ $template_data[ 'persons' ] = $persons;
1173
+
1174
+ break;
1175
+ }
1176
+
1177
+ return include WCML_PLUGIN_PATH . '/compatibility/templates/wc_bookings_custom_box_html.php';
1178
+
1179
+ }
1180
+
1181
+ return $html;
1182
+ }
1183
+
1184
+ function product_content_fields( $fields, $product_id ){
1185
+
1186
+ return $this->product_content_fields_data( $fields, $product_id );
1187
+
1188
+ }
1189
+
1190
+ function product_content_fields_label( $fields, $product_id ){
1191
+
1192
+ return $this->product_content_fields_data( $fields, $product_id, 'label' );
1193
+
1194
+ }
1195
+
1196
+ function product_content_fields_data( $fields, $product_id, $data = false ){
1197
+
1198
+ if( get_post_meta( $product_id, '_resource_base_costs', true ) ){
1199
+ if( $data == 'label' ){
1200
+ $fields[] = __( 'Resources', 'wpml-wcml' );
1201
+ }else{
1202
+ $fields[] = 'wc_booking_resources';
1203
+ }
1204
+ }
1205
+
1206
+ if( has_term( 'booking', 'product_type', $product_id ) ){
1207
+ global $wpdb;
1208
+
1209
+ $persons = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'bookable_person'", $product_id ) );
1210
+
1211
+ if( $persons ){
1212
+ if( $data == 'label' ){
1213
+ $fields[] = __( 'Person types', 'wpml-wcml' );
1214
+ }else{
1215
+ $fields[] = 'wc_booking_persons';
1216
+ }
1217
+ }
1218
+
1219
+ }
1220
+
1221
+ return $fields;
1222
+
1223
+ }
1224
+
1225
+ function show_custom_blocks_for_resources_and_persons( $check, $product_id, $product_content ){
1226
+ if( in_array( $product_content, array( 'wc_booking_resources', 'wc_booking_persons' ) ) ){
1227
+ return false;
1228
+ }
1229
+ return $check;
1230
+ }
1231
+
1232
+ function remove_custom_fields_to_translate( $exception, $product_id, $meta_key ){
1233
+ if( in_array( $meta_key, array( '_resource_base_costs', '_resource_block_costs' ) ) ){
1234
+ $exception = true;
1235
+ }
1236
+ return $exception;
1237
+ }
1238
+
1239
+ function product_content_resource_label( $meta_key, $product_id ){
1240
+ if ($meta_key == '_wc_booking_resouce_label'){
1241
+ return __( 'Resources label', 'wpml-wcml' );
1242
+ }
1243
+ return $meta_key;
1244
+ }
1245
+
1246
+ function wcml_products_tab_sync_resources_and_persons( $tr_product_id, $data, $language ){
1247
+ global $wpdb, $woocommerce_wpml;
1248
+
1249
+ //sync resources
1250
+ if( isset( $data[ 'wc_booking_resources_'.$language ] ) ){
1251
+
1252
+ $original_product_lang = $woocommerce_wpml->products->get_original_product_language( $tr_product_id );
1253
+ $original_product_id = icl_object_id( $tr_product_id, 'product', true, $original_product_lang );
1254
+
1255
+ foreach( $data[ 'wc_booking_resources_'.$language ][ 'id' ] as $key => $resource_id ){
1256
+
1257
+ if( !$resource_id ){
1258
+
1259
+ $resource_id = icl_object_id( $data[ 'wc_booking_resources_'.$language ][ 'orig_id' ][ $key ], 'bookable_resource', false, $language );
1260
+
1261
+ $orig_resource = $wpdb->get_row( $wpdb->prepare( "SELECT resource_id, sort_order FROM {$wpdb->prefix}wc_booking_relationships WHERE resource_id = %d AND product_id = %d", $data[ 'wc_booking_resources_'.$language ][ 'orig_id' ][ $key ], $original_product_id ), OBJECT );
1262
+
1263
+ if( is_null( $resource_id ) ){
1264
+
1265
+ if( $orig_resource ) {
1266
+ $resource_id = $this->duplicate_resource($tr_product_id, $orig_resource, $language);
1267
+ }else{
1268
+ continue;
1269
+ }
1270
+
1271
+ }else{
1272
+ //update_relationship
1273
+
1274
+ $exist = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}wc_booking_relationships WHERE resource_id = %d AND product_id = %d", $resource_id, $tr_product_id ) );
1275
+
1276
+ if( !$exist ){
1277
+
1278
+ $wpdb->insert(
1279
+ $wpdb->prefix . 'wc_booking_relationships',
1280
+ array(
1281
+ 'product_id' => $tr_product_id,
1282
+ 'resource_id' => $resource_id,
1283
+ 'sort_order' => $orig_resource->sort_order
1284
+ )
1285
+ );
1286
+
1287
+ }
1288
+
1289
+ }
1290
+
1291
+ }
1292
+
1293
+ $wpdb->update(
1294
+ $wpdb->posts,
1295
+ array(
1296
+ 'post_title' => $data[ 'wc_booking_resources_'.$language ][ 'title' ][ $key ]
1297
+ ),
1298
+ array(
1299
+ 'ID' => $resource_id
1300
+ )
1301
+ );
1302
+
1303
+ }
1304
+
1305
+ //sync resources data
1306
+ $this->sync_resources( $original_product_id, $tr_product_id, $language, false );
1307
+
1308
+ remove_filter( 'update_post_metadata', array( $this, 'update_wc_booking_costs' ), 10, 5 );
1309
+ $this->sync_resource_costs( $original_product_id, $tr_product_id, '_resource_base_costs', $language );
1310
+ $this->sync_resource_costs( $original_product_id, $tr_product_id, '_resource_block_costs', $language );
1311
+ add_filter( 'update_post_metadata', array( $this, 'update_wc_booking_costs' ), 10, 5 );
1312
+
1313
+ }
1314
+
1315
+
1316
+ //sync persons
1317
+ if( isset( $data[ 'wc_booking_persons_'.$language ] ) ){
1318
+
1319
+ $original_product_lang = $woocommerce_wpml->products->get_original_product_language( $tr_product_id );
1320
+ $original_product_id = icl_object_id( $tr_product_id, 'product', true, $original_product_lang );
1321
+
1322
+ foreach( $data[ 'wc_booking_persons_'.$language ][ 'id' ] as $key => $person_id ) {
1323
+
1324
+ if ( !$person_id ) {
1325
+
1326
+ $person_id = icl_object_id( $data[ 'wc_booking_persons_'.$language ][ 'orig_id' ][ $key ], 'bookable_person', false, $language );
1327
+
1328
+ if( is_null( $person_id ) ){
1329
+
1330
+ $person_id = $this->duplicate_person( $tr_product_id, $data['wc_booking_persons_' . $language]['orig_id'][$key], $language);
1331
+
1332
+ }else{
1333
+
1334
+ $wpdb->update(
1335
+ $wpdb->posts,
1336
+ array(
1337
+ 'post_parent' => $tr_product_id
1338
+ ),
1339
+ array(
1340
+ 'ID' => $person_id
1341
+ )
1342
+ );
1343
+
1344
+ }
1345
+
1346
+ }
1347
+
1348
+ $wpdb->update(
1349
+ $wpdb->posts,
1350
+ array(
1351
+ 'post_title' => $data[ 'wc_booking_persons_' . $language ][ 'title' ][ $key ],
1352
+ 'post_excerpt' => $data[ 'wc_booking_persons_' . $language ][ 'description' ][ $key ],
1353
+ ),
1354
+ array(
1355
+ 'ID' => $person_id
1356
+ )
1357
+ );
1358
+
1359
+ }
1360
+
1361
+ //sync persons data
1362
+ $this->sync_persons( $original_product_id, $tr_product_id, $language, false );
1363
+
1364
+ }
1365
+
1366
+ }
1367
+
1368
+ }
compatibility/wc_extra_product_options.class.php CHANGED
@@ -114,7 +114,7 @@ class WCML_Extra_Product_Options{
114
 
115
  function inf_message( $text ){
116
  $message = '<div><p class="icl_cyan_box">';
117
- $message .= sprintf(__('To translate Extra Options strings please save %s and go to the <b><a href="%s">String Translation interface</a></b>', 'wpml-wcml'), $text, 'admin.php?page=wpml-string-translation/menu/string-translation.php&context=wc_extra_product_options');
118
  $message .= '</p></div>';
119
 
120
  echo $message;
114
 
115
  function inf_message( $text ){
116
  $message = '<div><p class="icl_cyan_box">';
117
+ $message .= sprintf(__('To translate Extra Options strings please save %s and go to the <b><a href="%s">String Translation interface</a></b>', 'wpml-wcml'), $text, admin_url('admin.php?page='.WPML_ST_FOLDER.'/menu/string-translation.php&context=wc_extra_product_options'));
118
  $message .= '</p></div>';
119
 
120
  echo $message;
compatibility/wc_product_addons.class.php CHANGED
@@ -67,7 +67,7 @@ class WCML_Product_Addons{
67
 
68
  function inf_translate_strings(){
69
  $message = '<div><p class="icl_cyan_box">';
70
- $message .= sprintf(__('To translate Add-ons strings please save Add-ons and go to the <b><a href="%s">String Translation interface</a></b>', 'wpml-wcml'), 'admin.php?page=wpml-string-translation/menu/string-translation.php&context=wc_product_addons_strings');
71
  $message .= '</p></div>';
72
 
73
  echo $message;
67
 
68
  function inf_translate_strings(){
69
  $message = '<div><p class="icl_cyan_box">';
70
+ $message .= sprintf(__('To translate Add-ons strings please save Add-ons and go to the <b><a href="%s">String Translation interface</a></b>', 'wpml-wcml'), admin_url('admin.php?page='.WPML_ST_FOLDER.'/menu/string-translation.php&context=wc_product_addons_strings'));
71
  $message .= '</p></div>';
72
 
73
  echo $message;
compatibility/wc_tab_manager.class.php CHANGED
@@ -4,7 +4,7 @@ class WCML_Tab_Manager{
4
 
5
  function __construct(){
6
  add_action( 'wcml_after_duplicate_product_post_meta', array( $this, 'sync_tabs' ), 10, 3 );
7
- add_filter( 'wcml_product_content_exception', array( $this, 'is_have_custom_product_tab' ), 10, 2 );
8
  add_filter( 'wcml_custom_box_html', array( $this, 'custom_box_html'), 10, 3 );
9
  add_filter( 'wpml_duplicate_custom_fields_exceptions', array( $this, 'duplicate_custom_fields_exceptions' ) );
10
  add_action( 'wcml_after_duplicate_product', array( $this, 'duplicate_product_tabs') , 10, 2 );
@@ -179,12 +179,14 @@ class WCML_Tab_Manager{
179
  return $exceptions;
180
  }
181
 
182
- function is_have_custom_product_tab($exception,$product_id){
183
- $prod_tabs = maybe_unserialize(get_post_meta($product_id,'_product_tabs',true));
184
- foreach($prod_tabs as $prod_tab){
185
- if(in_array($prod_tab['type'],array('product','core'))){
186
- $exception = false;
187
- break;
 
 
188
  }
189
  }
190
 
4
 
5
  function __construct(){
6
  add_action( 'wcml_after_duplicate_product_post_meta', array( $this, 'sync_tabs' ), 10, 3 );
7
+ add_filter( 'wcml_product_content_exception', array( $this, 'is_have_custom_product_tab' ), 10, 3 );
8
  add_filter( 'wcml_custom_box_html', array( $this, 'custom_box_html'), 10, 3 );
9
  add_filter( 'wpml_duplicate_custom_fields_exceptions', array( $this, 'duplicate_custom_fields_exceptions' ) );
10
  add_action( 'wcml_after_duplicate_product', array( $this, 'duplicate_product_tabs') , 10, 2 );
179
  return $exceptions;
180
  }
181
 
182
+ function is_have_custom_product_tab($exception,$product_id,$meta_key){
183
+ if( $meta_key == '_product_tabs'){
184
+ $prod_tabs = maybe_unserialize(get_post_meta($product_id,'_product_tabs',true));
185
+ foreach($prod_tabs as $prod_tab){
186
+ if(in_array($prod_tab['type'],array('product','core'))){
187
+ $exception = false;
188
+ break;
189
+ }
190
  }
191
  }
192
 
inc/ajax-setup.class.php CHANGED
@@ -70,24 +70,33 @@ class WCML_Ajax_Setup{
70
  return $value;
71
  }
72
 
73
- $checkout_page_id = get_option('woocommerce_checkout_page_id');
74
- $pay_page_id = get_option('woocommerce_pay_page_id');
75
- $cart_page_id = get_option('woocommerce_cart_page_id');
76
 
77
- $translated_checkout_page_id = icl_object_id($checkout_page_id, 'page', false);
78
- $translated_pay_page_id = icl_object_id($pay_page_id, 'page', false);
79
- $translated_cart_page_id = icl_object_id($cart_page_id, 'page', false);
80
-
 
 
 
 
 
 
 
 
 
 
 
81
 
82
- if($translated_cart_page_id == $post->ID){
83
  $value['is_cart'] = 1;
84
- $value['cart_url'] = get_permalink($translated_cart_page_id);
85
- } else if($translated_checkout_page_id == $post->ID || $checkout_page_id == $post->ID){
86
  $value['is_checkout'] = 1;
87
 
88
  $_SESSION['wpml_globalcart_language'] = $sitepress->get_current_language();
89
 
90
- } else if($translated_pay_page_id == $post->ID){
91
  $value['is_pay_page'] = 1;
92
  }
93
 
70
  return $value;
71
  }
72
 
73
+ $ch_pages = wp_cache_get('ch_pages', 'wcml_ch_pages');
 
 
74
 
75
+ if(empty($ch_pages)){
76
+
77
+ $ch_pages = array(
78
+
79
+ 'checkout_page_id' => get_option('woocommerce_checkout_page_id'),
80
+ 'pay_page_id' => get_option('woocommerce_pay_page_id'),
81
+ 'cart_page_id' => get_option('woocommerce_cart_page_id'));
82
+
83
+ $ch_pages['translated_checkout_page_id'] = icl_object_id($ch_pages['checkout_page_id'], 'page', false);
84
+ $ch_pages['translated_pay_page_id'] = icl_object_id($ch_pages['pay_page_id'], 'page', false);
85
+ $ch_pages['translated_cart_page_id'] = icl_object_id($ch_pages['cart_page_id'], 'page', false);
86
+
87
+ }
88
+
89
+ wp_cache_set( 'ch_pages', $ch_pages, 'wcml_ch_pages' );
90
 
91
+ if($ch_pages['translated_cart_page_id'] == $post->ID){
92
  $value['is_cart'] = 1;
93
+ $value['cart_url'] = get_permalink($ch_pages['translated_cart_page_id']);
94
+ } else if($ch_pages['translated_checkout_page_id'] == $post->ID || $ch_pages['checkout_page_id'] == $post->ID){
95
  $value['is_checkout'] = 1;
96
 
97
  $_SESSION['wpml_globalcart_language'] = $sitepress->get_current_language();
98
 
99
+ } else if($ch_pages['translated_pay_page_id'] == $post->ID){
100
  $value['is_pay_page'] = 1;
101
  }
102
 
inc/compatibility.class.php CHANGED
@@ -82,6 +82,12 @@ class WCML_Compatibility {
82
  $this->dynamic_pricing = new WCML_Dynamic_Pricing();
83
  }
84
 
 
 
 
 
 
 
85
  }
86
 
87
  }
82
  $this->dynamic_pricing = new WCML_Dynamic_Pricing();
83
  }
84
 
85
+ // WooCommerce Bookings
86
+ if(defined( 'WC_BOOKINGS_VERSION' ) && version_compare( WC_BOOKINGS_VERSION, '1.7.4', '>' )){
87
+ require_once WCML_PLUGIN_PATH . '/compatibility/wc_bookings.class.php';
88
+ $this->bookings = new WCML_Bookings();
89
+ }
90
+
91
  }
92
 
93
  }
inc/currency-switcher-widget.class.php CHANGED
@@ -18,7 +18,7 @@ class WC_Currency_Switcher_Widget extends WP_Widget {
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
  }
18
 
19
  function form( $instance ) {
20
 
21
+ printf('<p><a href="%s">%s</a></p>',admin_url('admin.php?page=wpml-wcml#currency-switcher'),__('Configure options','wpml-wcml'));
22
  return;
23
 
24
  }
inc/dependencies.class.php CHANGED
@@ -189,7 +189,7 @@ class WCML_Dependencies{
189
  // display messages
190
  if (!$allsame) {
191
  $this->err_message = '<div class="message error"><p>'.printf(__('If you want different slugs for shop pages (%s/%s), you need to disable the shop prefix for products in <a href="%s">WooCommerce Settings</a>', 'wpml-wcml'),
192
- $slug, $translated_slug, "admin.php?page=woocommerce_settings&tab=pages").'</p></div>';
193
  add_action('admin_notices', array($this,'plugin_notice_message'));
194
  }
195
 
189
  // display messages
190
  if (!$allsame) {
191
  $this->err_message = '<div class="message error"><p>'.printf(__('If you want different slugs for shop pages (%s/%s), you need to disable the shop prefix for products in <a href="%s">WooCommerce Settings</a>', 'wpml-wcml'),
192
+ $slug, $translated_slug, admin_url("admin.php?page=woocommerce_settings&tab=pages")).'</p></div>';
193
  add_action('admin_notices', array($this,'plugin_notice_message'));
194
  }
195
 
inc/endpoints.class.php CHANGED
@@ -10,6 +10,7 @@ class WCML_Endpoints{
10
  $this->register_endpoints_translations();
11
  add_action( 'icl_ajx_custom_call', array( $this, 'rewrite_rule_endpoints' ), 11, 2 );
12
  add_action( 'woocommerce_update_options', array( $this, 'update_endpoints_rules' ) );
 
13
 
14
  add_filter( 'page_link', array( $this, 'endpoint_permalink_filter' ), 10, 2 ); //after WPML
15
 
@@ -66,6 +67,13 @@ class WCML_Endpoints{
66
  }
67
  }
68
 
 
 
 
 
 
 
 
69
  function update_endpoints_rules(){
70
  $this->add_endpoints();
71
  }
10
  $this->register_endpoints_translations();
11
  add_action( 'icl_ajx_custom_call', array( $this, 'rewrite_rule_endpoints' ), 11, 2 );
12
  add_action( 'woocommerce_update_options', array( $this, 'update_endpoints_rules' ) );
13
+ add_filter( 'pre_update_option_rewrite_rules', array( $this, 'update_rewrite_rules' ), 100, 2 );
14
 
15
  add_filter( 'page_link', array( $this, 'endpoint_permalink_filter' ), 10, 2 ); //after WPML
16
 
67
  }
68
  }
69
 
70
+ function update_rewrite_rules( $value, $old_value ){
71
+ remove_filter( 'pre_update_option_rewrite_rules', array( $this, 'update_rewrite_rules' ), 100, 2 );
72
+ $this->add_endpoints();
73
+ flush_rewrite_rules();
74
+ return $value;
75
+ }
76
+
77
  function update_endpoints_rules(){
78
  $this->add_endpoints();
79
  }
inc/multi-currency-support.class.php CHANGED
@@ -648,7 +648,7 @@ class WCML_Multi_Currency_Support{
648
  $currency_code = $this->client_currency;
649
  }
650
 
651
- return $currency_code;
652
 
653
  }
654
 
@@ -662,6 +662,9 @@ class WCML_Multi_Currency_Support{
662
  load_currency(currency);
663
  });
664
  jQuery('.wcml_currency_switcher li').on('click', function(){
 
 
 
665
  var currency = jQuery(this).attr('rel');
666
  load_currency(currency);
667
  });
@@ -1076,13 +1079,26 @@ class WCML_Multi_Currency_Support{
1076
  }
1077
 
1078
  function get_client_currency(){
1079
- global $woocommerce, $woocommerce_wpml, $sitepress;
1080
 
1081
  $default_currencies = $woocommerce_wpml->settings['default_currencies'];
1082
  $current_language = $sitepress->get_current_language();
1083
  $current_language = ( $current_language != 'all' && !is_null( $current_language ) ) ? $current_language : $sitepress->get_default_language();
1084
  $active_languages = $sitepress->get_active_languages();
1085
-
 
 
 
 
 
 
 
 
 
 
 
 
 
1086
  if(isset($_POST['action']) && $_POST['action'] == 'wcml_switch_currency' && !empty($_POST['currency'])){
1087
  $this->client_currency = filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
1088
  }
@@ -1261,10 +1277,29 @@ class WCML_Multi_Currency_Support{
1261
 
1262
  function currency_switcher($args = array()){
1263
  global $sitepress, $woocommerce_wpml;
1264
- if ( is_page( get_option( 'woocommerce_myaccount_page_id' ) ) ) {
 
1265
  return '';
1266
  }
 
1267
  $settings = $woocommerce_wpml->get_settings();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1268
  if(!isset($args['switcher_style'])){
1269
  $args['switcher_style'] = isset($settings['currency_switcher_style'])?$settings['currency_switcher_style']:'dropdown';
1270
  }
@@ -1287,29 +1322,35 @@ class WCML_Multi_Currency_Support{
1287
  }
1288
 
1289
  if($args['switcher_style'] == 'dropdown'){
1290
- echo '<select class="wcml_currency_switcher">';
1291
  }else{
1292
  $args['orientation'] = $args['orientation'] == 'horizontal'?'curr_list_horizontal':'curr_list_vertical';
1293
  echo '<ul class="wcml_currency_switcher '.$args['orientation'].'">';
1294
  }
 
1295
  foreach($currencies as $currency){
1296
  if($woocommerce_wpml->settings['currency_options'][$currency]['languages'][$sitepress->get_current_language()] == 1 ){
1297
- $selected = $currency == $this->get_client_currency() ? ' selected="selected"' : '';
1298
 
1299
  $currency_format = preg_replace(array('#%name%#', '#%symbol%#', '#%code%#'),
1300
  array($wc_currencies[$currency], get_woocommerce_currency_symbol($currency), $currency), $args['format']);
 
1301
  if($args['switcher_style'] == 'dropdown'){
1302
- echo '<option value="' . $currency . '"' . $selected . '>' . $currency_format . '</option>';
 
1303
  }else{
1304
- echo '<li rel="' . $currency . '" >' . $currency_format . '</li>';
 
 
1305
  }
1306
  }
1307
- }
1308
  if($args['switcher_style'] == 'dropdown'){
1309
- echo '</select>';
1310
  }else{
1311
  echo '</ul>';
1312
  }
 
1313
  }
1314
 
1315
  function register_styles(){
648
  $currency_code = $this->client_currency;
649
  }
650
 
651
+ return apply_filters( 'wcml_filter_currency_position', $currency_code );
652
 
653
  }
654
 
662
  load_currency(currency);
663
  });
664
  jQuery('.wcml_currency_switcher li').on('click', function(){
665
+ if(jQuery(this).hasClass('wcml-active-currency')){
666
+ return;
667
+ }
668
  var currency = jQuery(this).attr('rel');
669
  load_currency(currency);
670
  });
1079
  }
1080
 
1081
  function get_client_currency(){
1082
+ global $woocommerce, $woocommerce_wpml, $sitepress, $wp_query;
1083
 
1084
  $default_currencies = $woocommerce_wpml->settings['default_currencies'];
1085
  $current_language = $sitepress->get_current_language();
1086
  $current_language = ( $current_language != 'all' && !is_null( $current_language ) ) ? $current_language : $sitepress->get_default_language();
1087
  $active_languages = $sitepress->get_active_languages();
1088
+
1089
+ if( is_product() &&
1090
+ isset($woocommerce_wpml->settings['display_custom_prices']) &&
1091
+ $woocommerce_wpml->settings['display_custom_prices'] ){
1092
+
1093
+ $current_product_id = wc_get_product()->id;
1094
+ $original_product_language = $woocommerce_wpml->products->get_original_product_language( $current_product_id );
1095
+
1096
+ if( !get_post_meta( icl_object_id( $current_product_id , get_post_type( $current_product_id ), true, $original_product_language ), '_wcml_custom_prices_status', true ) ){
1097
+ $this->client_currency = get_option('woocommerce_currency');
1098
+ }
1099
+
1100
+ }
1101
+
1102
  if(isset($_POST['action']) && $_POST['action'] == 'wcml_switch_currency' && !empty($_POST['currency'])){
1103
  $this->client_currency = filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
1104
  }
1277
 
1278
  function currency_switcher($args = array()){
1279
  global $sitepress, $woocommerce_wpml;
1280
+
1281
+ if ( is_page( wc_get_page_id('myaccount') ) ) {
1282
  return '';
1283
  }
1284
+
1285
  $settings = $woocommerce_wpml->get_settings();
1286
+
1287
+ if( isset($settings['display_custom_prices']) && $settings['display_custom_prices'] ){
1288
+
1289
+ if( is_page( wc_get_page_id('cart') ) ||
1290
+ is_page( wc_get_page_id('checkout') ) ){
1291
+ return '';
1292
+ }elseif ( is_product() ){
1293
+ $current_product_id = wc_get_product()->id;
1294
+ $original_product_language = $woocommerce_wpml->products->get_original_product_language( $current_product_id );
1295
+
1296
+ if( !get_post_meta( icl_object_id( $current_product_id , get_post_type( $current_product_id ), true, $original_product_language ), '_wcml_custom_prices_status', true ) ){
1297
+ return '';
1298
+ }
1299
+ }
1300
+
1301
+ }
1302
+
1303
  if(!isset($args['switcher_style'])){
1304
  $args['switcher_style'] = isset($settings['currency_switcher_style'])?$settings['currency_switcher_style']:'dropdown';
1305
  }
1322
  }
1323
 
1324
  if($args['switcher_style'] == 'dropdown'){
1325
+ echo '<select class="wcml_currency_switcher">';
1326
  }else{
1327
  $args['orientation'] = $args['orientation'] == 'horizontal'?'curr_list_horizontal':'curr_list_vertical';
1328
  echo '<ul class="wcml_currency_switcher '.$args['orientation'].'">';
1329
  }
1330
+
1331
  foreach($currencies as $currency){
1332
  if($woocommerce_wpml->settings['currency_options'][$currency]['languages'][$sitepress->get_current_language()] == 1 ){
1333
+
1334
 
1335
  $currency_format = preg_replace(array('#%name%#', '#%symbol%#', '#%code%#'),
1336
  array($wc_currencies[$currency], get_woocommerce_currency_symbol($currency), $currency), $args['format']);
1337
+
1338
  if($args['switcher_style'] == 'dropdown'){
1339
+ $selected = $currency == $this->get_client_currency() ? ' selected="selected"' : '';
1340
+ echo '<option value="' . $currency . '"' . $selected . '>' . $currency_format . '</option>';
1341
  }else{
1342
+ $selected = $currency == $this->get_client_currency() ? ' class="wcml-active-currency"' : '';
1343
+ echo '<li rel="' . $currency . '" '.$selected.' >' . $currency_format . '</li>';
1344
+ }
1345
  }
1346
  }
1347
+
1348
  if($args['switcher_style'] == 'dropdown'){
1349
+ echo '</select>';
1350
  }else{
1351
  echo '</ul>';
1352
  }
1353
+
1354
  }
1355
 
1356
  function register_styles(){
inc/multi-currency.class.php CHANGED
@@ -311,7 +311,14 @@ class WCML_WC_MultiCurrency{
311
  }
312
 
313
  function currency_switcher(){
314
- echo(do_shortcode('[currency_switcher]'));
 
 
 
 
 
 
 
315
  }
316
 
317
  function get_client_currency(){
@@ -382,7 +389,6 @@ class WCML_WC_MultiCurrency{
382
  <?php endforeach; ?>
383
  </select>
384
  <?php
385
- wc_enqueue_js( "jQuery('select#dropdown_shop_order_currency, select[name=m]').css('width', '180px').chosen();");
386
 
387
  }
388
 
311
  }
312
 
313
  function currency_switcher(){
314
+ global $woocommerce_wpml;
315
+
316
+ $settings = $woocommerce_wpml->get_settings();
317
+
318
+ if( is_product() && isset($settings['currency_switcher_product_visibility']) && $settings['currency_switcher_product_visibility'] === 1 ){
319
+ echo(do_shortcode('[currency_switcher]'));
320
+ }
321
+
322
  }
323
 
324
  function get_client_currency(){
389
  <?php endforeach; ?>
390
  </select>
391
  <?php
 
392
 
393
  }
394
 
inc/products.class.php CHANGED
@@ -50,7 +50,9 @@ class WCML_Products{
50
  add_filter( 'post_row_actions', array( $this, 'filter_product_actions' ), 10, 2 );
51
 
52
  }else{
53
- add_filter( 'woocommerce_json_search_found_products', array( $this, 'filter_found_products_by_language' ) );
 
 
54
  }
55
  add_filter( 'woocommerce_restore_order_stock_quantity', array( $this, 'woocommerce_restore_order_stock_quantity' ), 10, 2 );
56
 
@@ -126,9 +128,6 @@ class WCML_Products{
126
  add_action('wp_ajax_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),0);
127
  add_action('wp_ajax_nopriv_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),0);
128
  add_action('wp_ajax_nopriv_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),0);
129
- if(!is_admin()){
130
- wp_enqueue_script('wcml-scripts', WCML_PLUGIN_URL . '/assets/js/cart_widget.js', array('jquery'), WCML_VERSION);
131
- }
132
  }
133
 
134
  function get_product($product_id) {
@@ -487,14 +486,24 @@ class WCML_Products{
487
  $product_parent = icl_object_id($orig_product->post_parent, 'product', false, $language);
488
  $args['post_parent'] = is_null($product_parent) ? 0 : $product_parent;
489
  $_POST['to_lang'] = $language;
 
490
  wp_update_post($args);
491
 
 
 
 
 
 
 
 
 
 
492
  $sitepress->set_element_language_details($tr_product_id, 'post_' . $orig_product->post_type, $product_trid, $language);
493
  $this->duplicate_product_post_meta($original_product_id, $tr_product_id, $data);
494
 
495
  }
496
 
497
- do_action('wcml_update_extra_fields',$tr_product_id,$data);
498
 
499
  //get "_product_attributes" from original product
500
  $orig_product_attrs = $this->get_product_atributes($original_product_id);
@@ -551,6 +560,7 @@ class WCML_Products{
551
  }
552
  }
553
 
 
554
  $translations = $sitepress->get_element_translations( $product_trid, 'post_product', false, false, true );
555
  if(ob_get_length()){
556
  ob_clean();
@@ -561,10 +571,12 @@ class WCML_Products{
561
  $this->get_translation_statuses($translations,$languages,isset($_POST['slang']) && $_POST['slang'] != 'all'?$_POST['slang']:false, $product_trid);
562
  $return['status'] = ob_get_clean();
563
 
 
564
  ob_start();
565
  $this->product_images_box($tr_product_id,$language);
566
  $return['images'][$language] = ob_get_clean();
567
 
 
568
  $is_variable_product = $this->is_variable_product($original_product_id);
569
 
570
  if($is_variable_product && !$woocommerce_wpml->settings['file_path_sync'] && $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT){
@@ -576,8 +588,12 @@ class WCML_Products{
576
  // no longer a duplicate
577
  if(!empty($data['end_duplication'][$original_product_id][$language])){
578
  delete_post_meta($tr_product_id, '_icl_lang_duplicate_of', $original_product_id);
 
579
  }
580
 
 
 
 
581
  echo json_encode($return);
582
  die();
583
  }
@@ -1119,7 +1135,7 @@ class WCML_Products{
1119
  $trnsl_up_sells = array();
1120
  if($original_up_sells) {
1121
  foreach ($original_up_sells as $original_up_sell_product) {
1122
- $trnsl_up_sells[] = icl_object_id($original_up_sell_product, 'post_' . get_post_type($original_up_sell_product), false, $lang);
1123
  }
1124
  }
1125
 
@@ -1130,7 +1146,7 @@ class WCML_Products{
1130
  $trnsl_cross_sells = array();
1131
  if( $original_cross_sells )
1132
  foreach( $original_cross_sells as $original_cross_sell_product ){
1133
- $trnsl_cross_sells[] = icl_object_id( $original_cross_sell_product, 'post_'.get_post_type( $original_cross_sell_product ), false, $lang );
1134
  }
1135
  update_post_meta( $tr_product_id, '_crosssell_ids', $trnsl_cross_sells );
1136
 
@@ -1228,7 +1244,7 @@ class WCML_Products{
1228
 
1229
  function inf_editing_product_in_non_default_lang(){
1230
  $message = '<div class="message error"><p>';
1231
- $message .= sprintf(__('The recommended way to translate WooCommerce products is using the <b><a href="%s">WooCommerce Multilingual products translation</a></b> page. Please use this page only for translating elements that are not available in the WooCommerce Multilingual products translation table.', 'wpml-wcml'), 'admin.php?page=wpml-wcml&tab=products');
1232
  $message .= '</p></div>';
1233
 
1234
  echo $message;
@@ -1435,10 +1451,12 @@ class WCML_Products{
1435
  // Remove filter to avoid double sync
1436
  remove_action('save_post', array($this, 'sync_post_action'), 11, 2);
1437
 
 
 
1438
  //trnsl_interface option
1439
  if (!$woocommerce_wpml->settings['trnsl_interface'] && $original_language != $current_language ) {
1440
 
1441
- if( !isset( $_POST['wp-preview'] ) ){
1442
  $this->sync_status_and_parent( $duplicated_post_id, $post_id, $current_language );
1443
  $this->sync_product_data( $duplicated_post_id, $post_id, $current_language );
1444
  }
@@ -1464,10 +1482,11 @@ class WCML_Products{
1464
 
1465
  update_post_meta($post_id,'_wcml_custom_prices_status',$_POST['_wcml_custom_prices'][$post_id]);
1466
 
 
 
1467
  $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
1468
 
1469
- if($_POST['_wcml_custom_prices'][$post_id] == 1){
1470
- foreach($currencies as $code => $currency){
1471
  $sale_price = $_POST['_custom_sale_price'][$code];
1472
  $regular_price = $_POST['_custom_regular_price'][$code];
1473
 
@@ -1760,7 +1779,7 @@ class WCML_Products{
1760
  continue;
1761
  }
1762
  }else{
1763
- $exception = apply_filters('wcml_product_content_exception',true,$product_id);
1764
  if($exception){
1765
  continue;
1766
  }
@@ -1769,7 +1788,7 @@ class WCML_Products{
1769
  }
1770
  }
1771
 
1772
- return $contents;
1773
  }
1774
 
1775
  //get product content labels
@@ -1807,28 +1826,35 @@ class WCML_Products{
1807
  }
1808
  }
1809
  }else{
1810
- $exception = apply_filters('wcml_product_content_exception',true,$product_id);
1811
  if($exception){
1812
  continue;
1813
  }
1814
 
1815
  }
1816
 
 
 
 
 
 
 
1817
  $custom_key_label = str_replace('_',' ',$meta_key);
1818
- $contents[] = trim($custom_key_label[0]) ? ucfirst($custom_key_label) : ucfirst(substr($custom_key_label,1));
1819
 
1820
  }
1821
  }
1822
 
1823
- return $contents;
1824
  }
1825
 
1826
  function check_custom_field_is_single_value($product_id,$meta_key){
1827
- $meta_value = maybe_unserialize(get_post_meta($product_id,$meta_key,true));
 
1828
  if(is_array($meta_value)){
1829
  return false;
1830
  }else{
1831
- return true;
1832
  }
1833
 
1834
  }
@@ -1845,7 +1871,9 @@ class WCML_Products{
1845
  switch ($content) {
1846
  case 'title':
1847
  $tr_post = get_post($tr_post_id);
1848
- return $tr_post->post_title;
 
 
1849
  break;
1850
  case 'content':
1851
  $tr_post = get_post($tr_post_id);
@@ -2388,7 +2416,7 @@ class WCML_Products{
2388
  $tr_product_id = icl_object_id($cart_item['product_id'],'product',false,$current_language);
2389
 
2390
  if( $cart_item['product_id'] == $tr_product_id ){
2391
- $new_cart_data[$key] = $cart->cart_contents[$key];
2392
  continue;
2393
  }
2394
 
@@ -2825,15 +2853,32 @@ class WCML_Products{
2825
 
2826
  // Check if original product
2827
  function is_original_product( $product_id ){
 
 
 
 
 
 
 
 
2828
  global $wpdb;
2829
 
2830
  $is_original = $wpdb->get_var( $wpdb->prepare( "SELECT source_language_code IS NULL FROM {$wpdb->prefix}icl_translations WHERE element_id=%d AND element_type='post_product'", $product_id ) );
2831
 
 
 
2832
  return $is_original;
2833
  }
2834
 
2835
  // Get original product language
2836
  function get_original_product_language( $product_id ){
 
 
 
 
 
 
 
2837
  global $wpdb;
2838
 
2839
  $language = $wpdb->get_var( $wpdb->prepare( "
@@ -2841,6 +2886,8 @@ class WCML_Products{
2841
  LEFT JOIN {$wpdb->prefix}icl_translations as t2 ON t1.trid = t2.trid
2842
  WHERE t1.element_id=%d AND t1.element_type=%s AND t2.source_language_code IS NULL", $product_id, 'post_'.get_post_type($product_id) ) );
2843
 
 
 
2844
  return $language;
2845
  }
2846
 
@@ -2905,4 +2952,73 @@ class WCML_Products{
2905
 
2906
  }
2907
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2908
  }
50
  add_filter( 'post_row_actions', array( $this, 'filter_product_actions' ), 10, 2 );
51
 
52
  }else{
53
+ add_filter('woocommerce_json_search_found_products', array($this, 'filter_found_products_by_language'));
54
+ add_filter( 'loop_shop_post_in', array( $this, 'filter_products_with_custom_prices' ), 100 );
55
+ add_filter( 'woocommerce_related_products_args', array( $this, 'filter_related_products_args' ) );
56
  }
57
  add_filter( 'woocommerce_restore_order_stock_quantity', array( $this, 'woocommerce_restore_order_stock_quantity' ), 10, 2 );
58
 
128
  add_action('wp_ajax_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),0);
129
  add_action('wp_ajax_nopriv_woocommerce_get_refreshed_fragments',array($this,'wcml_refresh_fragments'),0);
130
  add_action('wp_ajax_nopriv_woocommerce_add_to_cart',array($this,'wcml_refresh_fragments'),0);
 
 
 
131
  }
132
 
133
  function get_product($product_id) {
486
  $product_parent = icl_object_id($orig_product->post_parent, 'product', false, $language);
487
  $args['post_parent'] = is_null($product_parent) ? 0 : $product_parent;
488
  $_POST['to_lang'] = $language;
489
+
490
  wp_update_post($args);
491
 
492
+ $post_name = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM {$wpdb->posts} WHERE ID=%d", $tr_product_id ));
493
+ if(isset( $data['post_name_' . $language]) && $post_name != $data['post_name_' . $language]){
494
+ // update post_name
495
+ // need set POST variable ( WPML used them when filtered this function)
496
+ $_POST[ 'new_title' ] = $data['title_' . $language];
497
+ $_POST[ 'new_slug' ] = $data['post_name_' . $language];
498
+ $new_slug = wp_unique_post_slug( $data['post_name_' . $language], $tr_product_id, $orig_product->post_status, $orig_product->post_type, $args['post_parent']);
499
+ }
500
+
501
  $sitepress->set_element_language_details($tr_product_id, 'post_' . $orig_product->post_type, $product_trid, $language);
502
  $this->duplicate_product_post_meta($original_product_id, $tr_product_id, $data);
503
 
504
  }
505
 
506
+ do_action('wcml_update_extra_fields',$tr_product_id,$data,$language);
507
 
508
  //get "_product_attributes" from original product
509
  $orig_product_attrs = $this->get_product_atributes($original_product_id);
560
  }
561
  }
562
 
563
+
564
  $translations = $sitepress->get_element_translations( $product_trid, 'post_product', false, false, true );
565
  if(ob_get_length()){
566
  ob_clean();
571
  $this->get_translation_statuses($translations,$languages,isset($_POST['slang']) && $_POST['slang'] != 'all'?$_POST['slang']:false, $product_trid);
572
  $return['status'] = ob_get_clean();
573
 
574
+
575
  ob_start();
576
  $this->product_images_box($tr_product_id,$language);
577
  $return['images'][$language] = ob_get_clean();
578
 
579
+
580
  $is_variable_product = $this->is_variable_product($original_product_id);
581
 
582
  if($is_variable_product && !$woocommerce_wpml->settings['file_path_sync'] && $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT){
588
  // no longer a duplicate
589
  if(!empty($data['end_duplication'][$original_product_id][$language])){
590
  delete_post_meta($tr_product_id, '_icl_lang_duplicate_of', $original_product_id);
591
+
592
  }
593
 
594
+ $old_slug = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM {$wpdb->posts} WHERE ID=%d", $tr_product_id ));
595
+ $return['slug'] = isset( $new_slug )? $new_slug : $old_slug;
596
+
597
  echo json_encode($return);
598
  die();
599
  }
1135
  $trnsl_up_sells = array();
1136
  if($original_up_sells) {
1137
  foreach ($original_up_sells as $original_up_sell_product) {
1138
+ $trnsl_up_sells[] = icl_object_id($original_up_sell_product, get_post_type($original_up_sell_product), false, $lang);
1139
  }
1140
  }
1141
 
1146
  $trnsl_cross_sells = array();
1147
  if( $original_cross_sells )
1148
  foreach( $original_cross_sells as $original_cross_sell_product ){
1149
+ $trnsl_cross_sells[] = icl_object_id( $original_cross_sell_product, get_post_type( $original_cross_sell_product ), false, $lang );
1150
  }
1151
  update_post_meta( $tr_product_id, '_crosssell_ids', $trnsl_cross_sells );
1152
 
1244
 
1245
  function inf_editing_product_in_non_default_lang(){
1246
  $message = '<div class="message error"><p>';
1247
+ $message .= sprintf(__('The recommended way to translate WooCommerce products is using the <b><a href="%s">WooCommerce Multilingual products translation</a></b> page. Please use this page only for translating elements that are not available in the WooCommerce Multilingual products translation table.', 'wpml-wcml'), admin_url('admin.php?page=wpml-wcml&tab=products'));
1248
  $message .= '</p></div>';
1249
 
1250
  echo $message;
1451
  // Remove filter to avoid double sync
1452
  remove_action('save_post', array($this, 'sync_post_action'), 11, 2);
1453
 
1454
+ do_action( 'wcml_before_sync_product', $duplicated_post_id, $post_id );
1455
+
1456
  //trnsl_interface option
1457
  if (!$woocommerce_wpml->settings['trnsl_interface'] && $original_language != $current_language ) {
1458
 
1459
+ if( !isset( $_POST['wp-preview'] ) || empty( $_POST['wp-preview'] ) ){
1460
  $this->sync_status_and_parent( $duplicated_post_id, $post_id, $current_language );
1461
  $this->sync_product_data( $duplicated_post_id, $post_id, $current_language );
1462
  }
1482
 
1483
  update_post_meta($post_id,'_wcml_custom_prices_status',$_POST['_wcml_custom_prices'][$post_id]);
1484
 
1485
+ if( $_POST['_wcml_custom_prices'][$post_id] == 1){
1486
+
1487
  $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
1488
 
1489
+ foreach( $currencies as $code => $currency ){
 
1490
  $sale_price = $_POST['_custom_sale_price'][$code];
1491
  $regular_price = $_POST['_custom_regular_price'][$code];
1492
 
1779
  continue;
1780
  }
1781
  }else{
1782
+ $exception = apply_filters('wcml_product_content_exception',true,$product_id,$meta_key);
1783
  if($exception){
1784
  continue;
1785
  }
1788
  }
1789
  }
1790
 
1791
+ return apply_filters('wcml_product_content_fields', $contents, $product_id );
1792
  }
1793
 
1794
  //get product content labels
1826
  }
1827
  }
1828
  }else{
1829
+ $exception = apply_filters('wcml_product_content_exception',true,$product_id,$meta_key);
1830
  if($exception){
1831
  continue;
1832
  }
1833
 
1834
  }
1835
 
1836
+ $custom_key_label = apply_filters( 'wcml_product_content_label', $meta_key, $product_id );
1837
+ if( $custom_key_label != $meta_key ){
1838
+ $contents[] = $custom_key_label;
1839
+ continue;
1840
+ }
1841
+
1842
  $custom_key_label = str_replace('_',' ',$meta_key);
1843
+ $contents[] = trim($custom_key_label[0]) ? ucfirst($custom_key_label) : ucfirst(substr($custom_key_label,1));
1844
 
1845
  }
1846
  }
1847
 
1848
+ return apply_filters('wcml_product_content_fields_label', $contents, $product_id);
1849
  }
1850
 
1851
  function check_custom_field_is_single_value($product_id,$meta_key){
1852
+
1853
+ $meta_value = maybe_unserialize( get_post_meta( $product_id, $meta_key, true ) );
1854
  if(is_array($meta_value)){
1855
  return false;
1856
  }else{
1857
+ return apply_filters( 'wcml_check_is_single', true, $product_id, $meta_key );
1858
  }
1859
 
1860
  }
1871
  switch ($content) {
1872
  case 'title':
1873
  $tr_post = get_post($tr_post_id);
1874
+ $tr_post_content['title'] = $tr_post->post_title;
1875
+ $tr_post_content['name'] = $tr_post->post_name;
1876
+ return $tr_post_content;
1877
  break;
1878
  case 'content':
1879
  $tr_post = get_post($tr_post_id);
2416
  $tr_product_id = icl_object_id($cart_item['product_id'],'product',false,$current_language);
2417
 
2418
  if( $cart_item['product_id'] == $tr_product_id ){
2419
+ $new_cart_data[$key] = apply_filters( 'wcml_cart_contents_not_changed', $cart->cart_contents[$key], $key, $current_language );
2420
  continue;
2421
  }
2422
 
2853
 
2854
  // Check if original product
2855
  function is_original_product( $product_id ){
2856
+
2857
+ $cache_key = $product_id;
2858
+ $cache_group = 'is_original_product';
2859
+
2860
+ $temp_is_original = wp_cache_get($cache_key, $cache_group);
2861
+ if($temp_is_original) return $temp_is_original;
2862
+
2863
+
2864
  global $wpdb;
2865
 
2866
  $is_original = $wpdb->get_var( $wpdb->prepare( "SELECT source_language_code IS NULL FROM {$wpdb->prefix}icl_translations WHERE element_id=%d AND element_type='post_product'", $product_id ) );
2867
 
2868
+ wp_cache_set( $cache_key, $is_original, $cache_group );
2869
+
2870
  return $is_original;
2871
  }
2872
 
2873
  // Get original product language
2874
  function get_original_product_language( $product_id ){
2875
+
2876
+ $cache_key = $product_id;
2877
+ $cache_group = 'original_product_language';
2878
+
2879
+ $temp_language = wp_cache_get( $cache_key, $cache_group );
2880
+ if($temp_language) return $temp_language;
2881
+
2882
  global $wpdb;
2883
 
2884
  $language = $wpdb->get_var( $wpdb->prepare( "
2886
  LEFT JOIN {$wpdb->prefix}icl_translations as t2 ON t1.trid = t2.trid
2887
  WHERE t1.element_id=%d AND t1.element_type=%s AND t2.source_language_code IS NULL", $product_id, 'post_'.get_post_type($product_id) ) );
2888
 
2889
+ wp_cache_set( $cache_key, $language, $cache_group );
2890
+
2891
  return $language;
2892
  }
2893
 
2952
 
2953
  }
2954
 
2955
+ // display products with custom prices only if enabled "Show only products with custom prices in secondary currencies" option on settings page
2956
+ function filter_products_with_custom_prices( $filtered_posts ) {
2957
+ global $wpdb,$woocommerce_wpml;
2958
+
2959
+ if( $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT &&
2960
+ isset($woocommerce_wpml->settings['display_custom_prices']) &&
2961
+ $woocommerce_wpml->settings['display_custom_prices'] ){
2962
+
2963
+ $client_currency = $woocommerce_wpml->multi_currency_support->get_client_currency();
2964
+ $woocommerce_currency = get_option('woocommerce_currency');
2965
+
2966
+ if( $client_currency == $woocommerce_currency ){
2967
+ return $filtered_posts;
2968
+ }
2969
+
2970
+ $matched_products = array();
2971
+
2972
+ $matched_products_query = $wpdb->get_results( "
2973
+ SELECT DISTINCT ID, post_parent, post_type FROM $wpdb->posts
2974
+ INNER JOIN $wpdb->postmeta ON ID = post_id
2975
+ WHERE post_type IN ( 'product', 'product_variation' ) AND post_status = 'publish' AND meta_key = '_wcml_custom_prices_status' AND meta_value = 1
2976
+ ", OBJECT_K );
2977
+
2978
+ if ( $matched_products_query ) {
2979
+ foreach ( $matched_products_query as $product ) {
2980
+ if( ! get_post_meta( $product->ID,'_price_'.$client_currency ) ) continue;
2981
+ if ( $product->post_type == 'product' )
2982
+ $matched_products[] = icl_object_id( $product->ID, 'post_'.get_post_type($product->ID), true );
2983
+ if ( $product->post_parent > 0 && ! in_array( $product->post_parent, $matched_products ) )
2984
+ $matched_products[] = icl_object_id( $product->post_parent, 'post_'.get_post_type($product->post_parent), true );
2985
+ }
2986
+ }
2987
+
2988
+ // Filter the id's
2989
+ if ( sizeof( $filtered_posts ) == 0) {
2990
+ $filtered_posts = $matched_products;
2991
+ $filtered_posts[] = 0;
2992
+ } else {
2993
+ $filtered_posts = array_intersect( $filtered_posts, $matched_products );
2994
+ $filtered_posts[] = 0;
2995
+ }
2996
+ }
2997
+
2998
+ return $filtered_posts;
2999
+ }
3000
+
3001
+ function filter_related_products_args( $args ){
3002
+ global $woocommerce_wpml;
3003
+
3004
+ if( $woocommerce_wpml->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT &&
3005
+ isset($woocommerce_wpml->settings['display_custom_prices']) &&
3006
+ $woocommerce_wpml->settings['display_custom_prices'] ){
3007
+
3008
+ $client_currency = $woocommerce_wpml->multi_currency_support->get_client_currency();
3009
+ $woocommerce_currency = get_option('woocommerce_currency');
3010
+
3011
+ if( $client_currency != $woocommerce_currency ){
3012
+ $args['meta_query'][] = array(
3013
+ 'key' => '_wcml_custom_prices_status',
3014
+ 'value' => 1,
3015
+ 'compare' => '=',
3016
+ );
3017
+ }
3018
+
3019
+ }
3020
+
3021
+ return $args;
3022
+ }
3023
+
3024
  }
inc/requests.class.php CHANGED
@@ -15,8 +15,9 @@ class WCML_Requests{
15
 
16
  if(isset($_POST['wcml_mc_options']) && check_admin_referer('wcml_mc_options', 'wcml_mc_options_nonce') && wp_verify_nonce($nonce, 'wcml_mc_options')){
17
 
18
- $woocommerce_wpml->settings['enable_multi_currency'] = $_POST['multi_currency'];
19
-
 
20
  //update default currency settings
21
  if( $_POST['multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
22
  $options = array(
@@ -42,7 +43,8 @@ class WCML_Requests{
42
  if(isset($_POST['currency_switcher_style'])) $woocommerce_wpml->settings['currency_switcher_style'] = $_POST['currency_switcher_style'];
43
  if(isset($_POST['wcml_curr_sel_orientation'])) $woocommerce_wpml->settings['wcml_curr_sel_orientation'] = $_POST['wcml_curr_sel_orientation'];
44
  if(isset($_POST['wcml_curr_template'])) $woocommerce_wpml->settings['wcml_curr_template'] = $_POST['wcml_curr_template'];
45
-
 
46
  $woocommerce_wpml->update_settings();
47
 
48
  }
15
 
16
  if(isset($_POST['wcml_mc_options']) && check_admin_referer('wcml_mc_options', 'wcml_mc_options_nonce') && wp_verify_nonce($nonce, 'wcml_mc_options')){
17
 
18
+ $woocommerce_wpml->settings['enable_multi_currency'] = $_POST['multi_currency'];
19
+ $woocommerce_wpml->settings['display_custom_prices'] = empty($_POST['display_custom_prices']) ? 0 : 1;
20
+
21
  //update default currency settings
22
  if( $_POST['multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
23
  $options = array(
43
  if(isset($_POST['currency_switcher_style'])) $woocommerce_wpml->settings['currency_switcher_style'] = $_POST['currency_switcher_style'];
44
  if(isset($_POST['wcml_curr_sel_orientation'])) $woocommerce_wpml->settings['wcml_curr_sel_orientation'] = $_POST['wcml_curr_sel_orientation'];
45
  if(isset($_POST['wcml_curr_template'])) $woocommerce_wpml->settings['wcml_curr_template'] = $_POST['wcml_curr_template'];
46
+ $woocommerce_wpml->settings['currency_switcher_product_visibility'] = empty($_POST['currency_switcher_product_visibility']) ? 0 : 1;
47
+
48
  $woocommerce_wpml->update_settings();
49
 
50
  }
inc/store-pages.class.php CHANGED
@@ -113,6 +113,11 @@ class WCML_Store_Pages{
113
  }
114
 
115
  function translate_pages_in_settings($id) {
 
 
 
 
 
116
  return icl_object_id($id, 'page', true);
117
  }
118
 
113
  }
114
 
115
  function translate_pages_in_settings($id) {
116
+ global $pagenow;
117
+ if( $pagenow == 'options-permalink.php' ){
118
+ return $id;
119
+ }
120
+
121
  return icl_object_id($id, 'page', true);
122
  }
123
 
inc/terms.class.php CHANGED
@@ -1073,7 +1073,7 @@ class WCML_Terms{
1073
 
1074
  return $out;
1075
  }
1076
-
1077
  function shipping_terms($terms, $post_id, $taxonomy){
1078
 
1079
  if( is_ajax() && isset($_POST['action']) && $_POST['action'] == 'woocommerce_update_order_review' ){
1073
 
1074
  return $out;
1075
  }
1076
+
1077
  function shipping_terms($terms, $post_id, $taxonomy){
1078
 
1079
  if( is_ajax() && isset($_POST['action']) && $_POST['action'] == 'woocommerce_update_order_review' ){
inc/upgrade.class.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  class WCML_Upgrade{
4
-
5
  private $versions = array(
6
 
7
  '2.9.9.1',
@@ -9,128 +9,129 @@ class WCML_Upgrade{
9
  '3.2',
10
  '3.3',
11
  '3.5',
12
- '3.5.4'
 
13
 
14
  );
15
-
16
  function __construct(){
17
 
18
  add_action('init', array($this, 'run'));
19
  add_action('init', array($this, 'setup_upgrade_notices'));
20
  add_action('admin_notices', array($this, 'show_upgrade_notices'));
21
-
22
  add_action('wp_ajax_wcml_hide_notice', array($this, 'hide_upgrade_notice'));
23
-
24
- }
25
-
26
  function setup_upgrade_notices(){
27
-
28
  $wcml_settings = get_option('_wcml_settings');
29
  $version_in_db = get_option('_wcml_version');
30
-
31
  if(!empty($version_in_db) && version_compare($version_in_db, '2.9.9.1', '<')){
32
  $n = 'varimages';
33
- $wcml_settings['notifications'][$n] =
34
  array(
35
- 'show' => 1,
36
  'text' => __('Looks like you are upgrading from a previous version of WooCommerce Multilingual. Would you like to automatically create translated variations and images?', 'wcml').
37
- '<br /><strong>' .
38
- ' <a href="' . admin_url('admin.php?page=' . basename(WCML_PLUGIN_PATH) . '/menu/sub/troubleshooting.php') . '">' . __('Yes, go to the troubleshooting page', 'wcml') . '</a> |' .
39
- ' <a href="#" onclick="jQuery.ajax({type:\'POST\',url: ajaxurl,data:\'action=wcml_hide_notice&notice='.$n.'\',success:function(){jQuery(\'#' . $n . '\').fadeOut()}});return false;">' . __('No - dismiss', 'wcml') . '</a>' .
40
- '</strong>'
41
  );
42
  update_option('_wcml_settings', $wcml_settings);
43
  }
44
-
45
  }
46
-
47
  function show_upgrade_notices(){
48
  $wcml_settings = get_option('_wcml_settings');
49
- if(!empty($wcml_settings['notifications'])){
50
  foreach($wcml_settings['notifications'] as $k => $notification){
51
-
52
  // exceptions
53
  if(isset($_GET['page']) && $_GET['page'] == basename(WCML_PLUGIN_PATH) . '/menu/sub/troubleshooting.php' && $k == 'varimages') continue;
54
-
55
  if($notification['show']){
56
  ?>
57
  <div id="<?php echo $k ?>" class="updated">
58
  <p><?php echo $notification['text'] ?></p>
59
  </div>
60
- <?php
61
  }
62
  }
63
  }
64
  }
65
-
66
  function hide_upgrade_notice($k){
67
-
68
  if(empty($k)){
69
  $k = $_POST['notice'];
70
  }
71
-
72
  $wcml_settings = get_option('_wcml_settings');
73
  if(isset($wcml_settings['notifications'][$k])){
74
  $wcml_settings['notifications'][$k]['show'] = 0;
75
  update_option('_wcml_settings', $wcml_settings);
76
  }
77
  }
78
-
79
  function run(){
80
-
81
  $version_in_db = get_option('_wcml_version');
82
-
83
  // exception - starting in 2.3.2
84
  if(empty($version_in_db) && get_option('icl_is_wcml_installed')){
85
  $version_in_db = '2.3.2';
86
  }
87
-
88
  $migration_ran = false;
89
-
90
  if($version_in_db && version_compare($version_in_db, WCML_VERSION, '<')){
91
-
92
  foreach($this->versions as $version){
93
-
94
  if(version_compare($version, WCML_VERSION, '<=') && version_compare($version, $version_in_db, '>')){
95
 
96
  $upgrade_method = 'upgrade_' . str_replace('.', '_', $version);
97
-
98
  if(method_exists($this, $upgrade_method)){
99
  $this->$upgrade_method();
100
  $migration_ran = true;
101
  }
102
-
103
  }
104
-
105
  }
106
-
107
  }
108
-
109
  if($migration_ran || empty($version_in_db)){
110
- update_option('_wcml_version', WCML_VERSION);
111
  }
112
  }
113
-
114
  function upgrade_2_9_9_1(){
115
  global $wpdb;
116
-
117
  //migrate exists currencies
118
  $currencies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` DESC");
119
  foreach($currencies as $currency){
120
  if(isset($currency->language_code)){
121
- $wpdb->insert($wpdb->prefix .'icl_languages_currencies', array(
122
- 'language_code' => $currency->language_code,
123
- 'currency_id' => $currency->id
124
- )
125
- );
126
- }
127
  }
128
 
129
- $cols = $wpdb->get_col("SHOW COLUMNS FROM {$wpdb->prefix}icl_currencies");
130
  if(in_array('language_code', $cols)){
131
  $wpdb->query("ALTER TABLE {$wpdb->prefix}icl_currencies DROP COLUMN language_code");
132
  }
133
-
134
  // migrate settings
135
  $new_settings = array(
136
  'is_term_order_synced' => get_option('icl_is_wcml_term_order_synched'),
@@ -140,52 +141,52 @@ class WCML_Upgrade{
140
  'enable_multi_currency' => get_option('icl_enable_multi_currency'),
141
  'currency_converting_option' => get_option('currency_converting_option')
142
  );
143
-
144
  if(!get_option('_wcml_settings')){
145
  add_option('_wcml_settings', $new_settings, false, true);
146
  }
147
-
148
  delete_option('icl_is_wcml_term_order_synced');
149
  delete_option('wcml_file_path_sync');
150
  delete_option('icl_is_wpcml_installed');
151
  delete_option('wpml_dismiss_doc_main');
152
  delete_option('icl_enable_multi_currency');
153
  delete_option('currency_converting_option');
154
-
155
-
156
  }
157
-
158
  function upgrade_3_1(){
159
  global $wpdb,$sitepress;
160
  $wcml_settings = get_option('_wcml_settings');
161
-
162
  if(isset($wcml_settings['enable_multi_currency']) && $wcml_settings['enable_multi_currency'] == 'yes'){
163
  $wcml_settings['enable_multi_currency'] = WCML_MULTI_CURRENCIES_INDEPENDENT;
164
  }else{
165
  $wcml_settings['enable_multi_currency'] = WCML_MULTI_CURRENCIES_DISABLED;
166
  }
167
-
168
  $wcml_settings['products_sync_date'] = 1;
169
-
170
-
171
  update_option('_wcml_settings', $wcml_settings);
172
-
173
  // multi-currency migration
174
  if($wcml_settings['enable_multi_currency'] == 'yes' && $wcml_settings['currency_converting_option'] == 2){
175
-
176
  // get currencies exchange rates
177
  $results = $wpdb->get_results("SELECT code, value FROM {$wpdb->prefix}icl_currencies");
178
  foreach($results as $row){
179
- $exchange_rates[$row->code] = $row->value;
180
  }
181
-
182
  // get languages currencies map
183
  $results = $wpdb->get_results("SELECT l.language_code, c.code FROM {$wpdb->prefix}icl_languages_currencies l JOIN {$wpdb->prefix}icl_currencies c ON l.currency_id = c.id");
184
  foreach($results as $row){
185
- $language_currencies[$row->language_code] = $row->code;
186
  }
187
-
188
-
189
  $results = $wpdb->get_results($wpdb->prepare("
190
  SELECT p.ID, t.trid, t.element_type
191
  FROM {$wpdb->posts} p JOIN {$wpdb->prefix}icl_translations t ON t.element_id = p.ID AND t.element_type IN ('post_product', 'post_product_variation')
@@ -193,7 +194,7 @@ class WCML_Upgrade{
193
  p.post_type in ('product', 'product_variation') AND t.language_code = %s
194
 
195
  ", $sitepress->get_default_language()));
196
-
197
  // set custom conversion rates
198
  foreach($results as $row){
199
  $translations = $sitepress->get_element_translations($row->trid, $row->element_type);
@@ -201,54 +202,54 @@ class WCML_Upgrade{
201
  $original_prices['_price'] = !empty($meta['_price']) ? $meta['_price'][0] : 0;
202
  $original_prices['_regular_price'] = !empty($meta['_regular_price']) ? $meta['_regular_price'][0] : 0;
203
  $original_prices['_sale_price'] = !empty($meta['_sale_price']) ? $meta['_sale_price'][0] : 0;
204
-
205
-
206
  $ccr = array();
207
-
208
  foreach($translations as $translation){
209
  if($translation->element_id != $row->ID){
210
-
211
  $meta = get_post_meta($translation->element_id);
212
  $translated_prices['_price'] = $meta['_price'][0];
213
  $translated_prices['_regular_price'] = $meta['_regular_price'][0];
214
  $translated_prices['_sale_price'] = $meta['_sale_price'][0];
215
 
216
  if(!empty($translated_prices['_price']) && !empty($original_prices['_price']) && $translated_prices['_price'] != $original_prices['_price']){
217
-
218
  $ccr['_price'][$language_currencies[$translation->language_code]] = $translated_prices['_price'] / $original_prices['_price'];
219
-
220
- }
221
  if(!empty($translated_prices['_regular_price']) && !empty($original_prices['_regular_price']) && $translated_prices['_regular_price'] != $original_prices['_regular_price']){
222
-
223
  $ccr['_regular_price'][$language_currencies[$translation->language_code]] = $translated_prices['_regular_price'] / $original_prices['_regular_price'];
224
-
225
- }
226
  if(!empty($translated_prices['_sale_price']) && !empty($original_prices['_sale_price']) && $translated_prices['_sale_price'] != $original_prices['_sale_price']){
227
-
228
  $ccr['_sale_price'][$language_currencies[$translation->language_code]] = $translated_prices['_sale_price'] / $original_prices['_sale_price'] ;
229
-
230
- }
231
-
232
-
233
  }
234
  }
235
-
236
  if($ccr){
237
- update_post_meta($row->ID, '_custom_conversion_rate', $ccr);
238
  }
239
-
240
-
241
  }
242
-
243
-
244
- }
245
-
246
  }
247
-
248
  function upgrade_3_2(){
249
-
250
  woocommerce_wpml::set_up_capabilities();
251
-
252
  //delete not existing currencies in WC
253
  global $wpdb;
254
  $currencies = $wpdb->get_results("SELECT id,code FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` DESC");
@@ -258,35 +259,35 @@ class WCML_Upgrade{
258
  $wpdb->delete( $wpdb->prefix . 'icl_currencies', array( 'ID' => $currency->id ) );
259
  }
260
  }
261
-
262
  }
263
-
264
  function upgrade_3_3(){
265
  global $wpdb, $woocommerce_wpml;
266
-
267
  woocommerce_wpml::set_up_capabilities();
268
 
269
  $currencies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` ASC", OBJECT);
270
  if($currencies)
271
- foreach($this->currencies as $currency){
272
-
273
- $woocommerce_wpml->settings['currency_options'][$currency->code]['rate'] = $currency->value;
274
- $woocommerce_wpml->settings['currency_options'][$currency->code]['updated'] = $currency->changed;
275
- $woocommerce_wpml->settings['currency_options'][$currency->code]['position'] = 'left';
276
- $woocommerce_wpml->settings['currency_options'][$currency->code]['languages'] = $woocommerce_wpml->settings['currencies_languages'];
277
- unset($woocommerce_wpml->settings['currencies_languages']);
278
-
279
- $woocommerce_wpml->update_settings();
280
-
281
- }
282
-
283
  $wpdb->query("DROP TABLE `{$wpdb->prefix}icl_currencies`");
284
-
285
  }
286
 
287
  function upgrade_3_5()
288
  {
289
- global $wpdb, $sitepress;
290
  $wcml_settings = get_option('_wcml_settings');
291
 
292
  $wcml_settings['products_sync_order'] = 1;
@@ -299,4 +300,15 @@ class WCML_Upgrade{
299
  flush_rewrite_rules( );
300
  }
301
 
 
 
 
 
 
 
 
 
 
 
 
302
  }
1
  <?php
2
 
3
  class WCML_Upgrade{
4
+
5
  private $versions = array(
6
 
7
  '2.9.9.1',
9
  '3.2',
10
  '3.3',
11
  '3.5',
12
+ '3.5.4',
13
+ '3.6'
14
 
15
  );
16
+
17
  function __construct(){
18
 
19
  add_action('init', array($this, 'run'));
20
  add_action('init', array($this, 'setup_upgrade_notices'));
21
  add_action('admin_notices', array($this, 'show_upgrade_notices'));
22
+
23
  add_action('wp_ajax_wcml_hide_notice', array($this, 'hide_upgrade_notice'));
24
+
25
+ }
26
+
27
  function setup_upgrade_notices(){
28
+
29
  $wcml_settings = get_option('_wcml_settings');
30
  $version_in_db = get_option('_wcml_version');
31
+
32
  if(!empty($version_in_db) && version_compare($version_in_db, '2.9.9.1', '<')){
33
  $n = 'varimages';
34
+ $wcml_settings['notifications'][$n] =
35
  array(
36
+ 'show' => 1,
37
  'text' => __('Looks like you are upgrading from a previous version of WooCommerce Multilingual. Would you like to automatically create translated variations and images?', 'wcml').
38
+ '<br /><strong>' .
39
+ ' <a href="' . admin_url('admin.php?page=' . basename(WCML_PLUGIN_PATH) . '/menu/sub/troubleshooting.php') . '">' . __('Yes, go to the troubleshooting page', 'wcml') . '</a> |' .
40
+ ' <a href="#" onclick="jQuery.ajax({type:\'POST\',url: ajaxurl,data:\'action=wcml_hide_notice&notice='.$n.'\',success:function(){jQuery(\'#' . $n . '\').fadeOut()}});return false;">' . __('No - dismiss', 'wcml') . '</a>' .
41
+ '</strong>'
42
  );
43
  update_option('_wcml_settings', $wcml_settings);
44
  }
45
+
46
  }
47
+
48
  function show_upgrade_notices(){
49
  $wcml_settings = get_option('_wcml_settings');
50
+ if(!empty($wcml_settings['notifications'])){
51
  foreach($wcml_settings['notifications'] as $k => $notification){
52
+
53
  // exceptions
54
  if(isset($_GET['page']) && $_GET['page'] == basename(WCML_PLUGIN_PATH) . '/menu/sub/troubleshooting.php' && $k == 'varimages') continue;
55
+
56
  if($notification['show']){
57
  ?>
58
  <div id="<?php echo $k ?>" class="updated">
59
  <p><?php echo $notification['text'] ?></p>
60
  </div>
61
+ <?php
62
  }
63
  }
64
  }
65
  }
66
+
67
  function hide_upgrade_notice($k){
68
+
69
  if(empty($k)){
70
  $k = $_POST['notice'];
71
  }
72
+
73
  $wcml_settings = get_option('_wcml_settings');
74
  if(isset($wcml_settings['notifications'][$k])){
75
  $wcml_settings['notifications'][$k]['show'] = 0;
76
  update_option('_wcml_settings', $wcml_settings);
77
  }
78
  }
79
+
80
  function run(){
81
+
82
  $version_in_db = get_option('_wcml_version');
83
+
84
  // exception - starting in 2.3.2
85
  if(empty($version_in_db) && get_option('icl_is_wcml_installed')){
86
  $version_in_db = '2.3.2';
87
  }
88
+
89
  $migration_ran = false;
90
+
91
  if($version_in_db && version_compare($version_in_db, WCML_VERSION, '<')){
92
+
93
  foreach($this->versions as $version){
94
+
95
  if(version_compare($version, WCML_VERSION, '<=') && version_compare($version, $version_in_db, '>')){
96
 
97
  $upgrade_method = 'upgrade_' . str_replace('.', '_', $version);
98
+
99
  if(method_exists($this, $upgrade_method)){
100
  $this->$upgrade_method();
101
  $migration_ran = true;
102
  }
103
+
104
  }
105
+
106
  }
107
+
108
  }
109
+
110
  if($migration_ran || empty($version_in_db)){
111
+ update_option('_wcml_version', WCML_VERSION);
112
  }
113
  }
114
+
115
  function upgrade_2_9_9_1(){
116
  global $wpdb;
117
+
118
  //migrate exists currencies
119
  $currencies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` DESC");
120
  foreach($currencies as $currency){
121
  if(isset($currency->language_code)){
122
+ $wpdb->insert($wpdb->prefix .'icl_languages_currencies', array(
123
+ 'language_code' => $currency->language_code,
124
+ 'currency_id' => $currency->id
125
+ )
126
+ );
127
+ }
128
  }
129
 
130
+ $cols = $wpdb->get_col("SHOW COLUMNS FROM {$wpdb->prefix}icl_currencies");
131
  if(in_array('language_code', $cols)){
132
  $wpdb->query("ALTER TABLE {$wpdb->prefix}icl_currencies DROP COLUMN language_code");
133
  }
134
+
135
  // migrate settings
136
  $new_settings = array(
137
  'is_term_order_synced' => get_option('icl_is_wcml_term_order_synched'),
141
  'enable_multi_currency' => get_option('icl_enable_multi_currency'),
142
  'currency_converting_option' => get_option('currency_converting_option')
143
  );
144
+
145
  if(!get_option('_wcml_settings')){
146
  add_option('_wcml_settings', $new_settings, false, true);
147
  }
148
+
149
  delete_option('icl_is_wcml_term_order_synced');
150
  delete_option('wcml_file_path_sync');
151
  delete_option('icl_is_wpcml_installed');
152
  delete_option('wpml_dismiss_doc_main');
153
  delete_option('icl_enable_multi_currency');
154
  delete_option('currency_converting_option');
155
+
156
+
157
  }
158
+
159
  function upgrade_3_1(){
160
  global $wpdb,$sitepress;
161
  $wcml_settings = get_option('_wcml_settings');
162
+
163
  if(isset($wcml_settings['enable_multi_currency']) && $wcml_settings['enable_multi_currency'] == 'yes'){
164
  $wcml_settings['enable_multi_currency'] = WCML_MULTI_CURRENCIES_INDEPENDENT;
165
  }else{
166
  $wcml_settings['enable_multi_currency'] = WCML_MULTI_CURRENCIES_DISABLED;
167
  }
168
+
169
  $wcml_settings['products_sync_date'] = 1;
170
+
171
+
172
  update_option('_wcml_settings', $wcml_settings);
173
+
174
  // multi-currency migration
175
  if($wcml_settings['enable_multi_currency'] == 'yes' && $wcml_settings['currency_converting_option'] == 2){
176
+
177
  // get currencies exchange rates
178
  $results = $wpdb->get_results("SELECT code, value FROM {$wpdb->prefix}icl_currencies");
179
  foreach($results as $row){
180
+ $exchange_rates[$row->code] = $row->value;
181
  }
182
+
183
  // get languages currencies map
184
  $results = $wpdb->get_results("SELECT l.language_code, c.code FROM {$wpdb->prefix}icl_languages_currencies l JOIN {$wpdb->prefix}icl_currencies c ON l.currency_id = c.id");
185
  foreach($results as $row){
186
+ $language_currencies[$row->language_code] = $row->code;
187
  }
188
+
189
+
190
  $results = $wpdb->get_results($wpdb->prepare("
191
  SELECT p.ID, t.trid, t.element_type
192
  FROM {$wpdb->posts} p JOIN {$wpdb->prefix}icl_translations t ON t.element_id = p.ID AND t.element_type IN ('post_product', 'post_product_variation')
194
  p.post_type in ('product', 'product_variation') AND t.language_code = %s
195
 
196
  ", $sitepress->get_default_language()));
197
+
198
  // set custom conversion rates
199
  foreach($results as $row){
200
  $translations = $sitepress->get_element_translations($row->trid, $row->element_type);
202
  $original_prices['_price'] = !empty($meta['_price']) ? $meta['_price'][0] : 0;
203
  $original_prices['_regular_price'] = !empty($meta['_regular_price']) ? $meta['_regular_price'][0] : 0;
204
  $original_prices['_sale_price'] = !empty($meta['_sale_price']) ? $meta['_sale_price'][0] : 0;
205
+
206
+
207
  $ccr = array();
208
+
209
  foreach($translations as $translation){
210
  if($translation->element_id != $row->ID){
211
+
212
  $meta = get_post_meta($translation->element_id);
213
  $translated_prices['_price'] = $meta['_price'][0];
214
  $translated_prices['_regular_price'] = $meta['_regular_price'][0];
215
  $translated_prices['_sale_price'] = $meta['_sale_price'][0];
216
 
217
  if(!empty($translated_prices['_price']) && !empty($original_prices['_price']) && $translated_prices['_price'] != $original_prices['_price']){
218
+
219
  $ccr['_price'][$language_currencies[$translation->language_code]] = $translated_prices['_price'] / $original_prices['_price'];
220
+
221
+ }
222
  if(!empty($translated_prices['_regular_price']) && !empty($original_prices['_regular_price']) && $translated_prices['_regular_price'] != $original_prices['_regular_price']){
223
+
224
  $ccr['_regular_price'][$language_currencies[$translation->language_code]] = $translated_prices['_regular_price'] / $original_prices['_regular_price'];
225
+
226
+ }
227
  if(!empty($translated_prices['_sale_price']) && !empty($original_prices['_sale_price']) && $translated_prices['_sale_price'] != $original_prices['_sale_price']){
228
+
229
  $ccr['_sale_price'][$language_currencies[$translation->language_code]] = $translated_prices['_sale_price'] / $original_prices['_sale_price'] ;
230
+
231
+ }
232
+
233
+
234
  }
235
  }
236
+
237
  if($ccr){
238
+ update_post_meta($row->ID, '_custom_conversion_rate', $ccr);
239
  }
240
+
241
+
242
  }
243
+
244
+
245
+ }
246
+
247
  }
248
+
249
  function upgrade_3_2(){
250
+
251
  woocommerce_wpml::set_up_capabilities();
252
+
253
  //delete not existing currencies in WC
254
  global $wpdb;
255
  $currencies = $wpdb->get_results("SELECT id,code FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` DESC");
259
  $wpdb->delete( $wpdb->prefix . 'icl_currencies', array( 'ID' => $currency->id ) );
260
  }
261
  }
262
+
263
  }
264
+
265
  function upgrade_3_3(){
266
  global $wpdb, $woocommerce_wpml;
267
+
268
  woocommerce_wpml::set_up_capabilities();
269
 
270
  $currencies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "icl_currencies ORDER BY `id` ASC", OBJECT);
271
  if($currencies)
272
+ foreach($this->currencies as $currency){
273
+
274
+ $woocommerce_wpml->settings['currency_options'][$currency->code]['rate'] = $currency->value;
275
+ $woocommerce_wpml->settings['currency_options'][$currency->code]['updated'] = $currency->changed;
276
+ $woocommerce_wpml->settings['currency_options'][$currency->code]['position'] = 'left';
277
+ $woocommerce_wpml->settings['currency_options'][$currency->code]['languages'] = $woocommerce_wpml->settings['currencies_languages'];
278
+ unset($woocommerce_wpml->settings['currencies_languages']);
279
+
280
+ $woocommerce_wpml->update_settings();
281
+
282
+ }
283
+
284
  $wpdb->query("DROP TABLE `{$wpdb->prefix}icl_currencies`");
285
+
286
  }
287
 
288
  function upgrade_3_5()
289
  {
290
+ global $wpdb;
291
  $wcml_settings = get_option('_wcml_settings');
292
 
293
  $wcml_settings['products_sync_order'] = 1;
300
  flush_rewrite_rules( );
301
  }
302
 
303
+ function upgrade_3_6()
304
+ {
305
+ global $wpdb;
306
+ $wcml_settings = get_option('_wcml_settings');
307
+
308
+ $wcml_settings['display_custom_prices'] = 0;
309
+ $wcml_settings['currency_switcher_product_visibility'] = 1;
310
+
311
+ update_option('_wcml_settings', $wcml_settings);
312
+ }
313
+
314
  }
inc/wc-rest-api-support.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WCML_WooCommerce_Rest_API_Support{
4
+
5
+
6
+ function __construct(){
7
+ add_action( 'parse_request', array( $this, 'use_canonical_home_url' ), -10 );
8
+ add_action( 'init', array( $this, 'init' ) );
9
+
10
+ }
11
+
12
+ function init(){
13
+ global $sitepress,$sitepress_settings;
14
+
15
+ //remove rewrite rules filtering for PayPal IPN url
16
+ if( strstr($_SERVER['REQUEST_URI'],'WC_Gateway_Paypal') && $sitepress_settings[ 'urls' ][ 'directory_for_default_language' ] ) {
17
+ remove_filter('option_rewrite_rules', array($sitepress, 'rewrite_rules_filter'));
18
+ }
19
+
20
+ }
21
+
22
+ // Use url without the language parameter. Needed for the signature match.
23
+ public function use_canonical_home_url(){
24
+ global $wp;
25
+
26
+ if(!empty($wp->query_vars['wc-api-version'])) {
27
+ global $wpml_url_filters;
28
+ remove_filter('home_url', array($wpml_url_filters, 'home_url_filter'), -10, 2);
29
+
30
+ }
31
+
32
+
33
+
34
+ }
35
+
36
+ }
37
+
38
+ ?>
inc/wc-strings.class.php CHANGED
@@ -86,8 +86,8 @@ class WCML_WC_Strings{
86
 
87
  function translated_cart_item_name($title, $values, $cart_item_key){
88
 
89
- $parent = $values['data']->post->post_parent;
90
  if($values){
 
91
  $tr_product_id = icl_object_id( $values['product_id'], 'product', true );
92
  $title = get_the_title($tr_product_id);
93
 
@@ -95,8 +95,13 @@ class WCML_WC_Strings{
95
  $tr_parent = icl_object_id( $parent, 'product', true );
96
  $title = get_the_title( $tr_parent ) . ' &rarr; ' . $title;
97
  }
98
-
99
- $title = sprintf( '<a href="%s">%s</a>', $values['data']->get_permalink(), $title );
 
 
 
 
 
100
 
101
  }
102
 
86
 
87
  function translated_cart_item_name($title, $values, $cart_item_key){
88
 
 
89
  if($values){
90
+ $parent = $values['data']->post->post_parent;
91
  $tr_product_id = icl_object_id( $values['product_id'], 'product', true );
92
  $title = get_the_title($tr_product_id);
93
 
95
  $tr_parent = icl_object_id( $parent, 'product', true );
96
  $title = get_the_title( $tr_parent ) . ' &rarr; ' . $title;
97
  }
98
+
99
+ if( wc_get_product( $tr_product_id )->is_visible() ){
100
+ $title = sprintf( '<a href="%s">%s</a>', $values['data']->get_permalink(), $title );
101
+ }else{
102
+ $title = $title. '&nbsp;';
103
+ }
104
+
105
 
106
  }
107
 
locale/wpml-wcml-ar.mo CHANGED
Binary file
locale/wpml-wcml-de_DE.mo CHANGED
Binary file
locale/wpml-wcml-el.mo CHANGED
Binary file
locale/wpml-wcml-es_ES.mo CHANGED
Binary file
locale/wpml-wcml-fr_FR.mo CHANGED
Binary file
locale/wpml-wcml-he_IL.mo CHANGED
Binary file
locale/wpml-wcml-it_IT.mo CHANGED
Binary file
locale/wpml-wcml-ja.mo CHANGED
Binary file
locale/wpml-wcml-ko_KR.mo CHANGED
Binary file
locale/wpml-wcml-nl_NL.mo CHANGED
Binary file
locale/wpml-wcml-pl_PL.mo CHANGED
Binary file
locale/wpml-wcml-pt_BR.mo CHANGED
Binary file
locale/wpml-wcml-pt_PT.mo CHANGED
Binary file
locale/wpml-wcml-ru_RU.mo CHANGED
Binary file
locale/wpml-wcml-sv_SE.mo CHANGED
Binary file
locale/wpml-wcml-vi.mo CHANGED
Binary file
locale/wpml-wcml-zh_CN.mo CHANGED
Binary file
locale/wpml-wcml-zh_TW.mo CHANGED
Binary file
menu/management.php CHANGED
@@ -34,12 +34,12 @@ if(isset($_GET['tab'])){
34
  <h2><?php _e('WooCommerce Multilingual', 'wpml-wcml') ?></h2>
35
 
36
  <?php if(current_user_can('wpml_manage_woocommerce_multilingual')): ?>
37
- <a class="nav-tab <?php echo $current_tab == 'settings' ?'nav-tab-active':''; ?>" href="admin.php?page=wpml-wcml"><?php _e('General settings', 'wpml-wcml') ?></a>
38
  <?php endif; ?>
39
- <a class="nav-tab <?php echo $current_tab == 'products' ? 'nav-tab-active' : ''; ?>" href="admin.php?page=wpml-wcml&tab=products"><?php _e('Products', 'wpml-wcml') ?></a>
40
  <?php if( current_user_can('wpml_operate_woocommerce_multilingual')): ?>
41
  <?php foreach($products_and_variation_taxonomies as $tax_key => $tax): if(!$sitepress->is_translated_taxonomy($tax_key)) continue; ?>
42
- <a class="nav-tab <?php echo (isset($_GET['tab']) && $_GET['tab'] == $tax_key)?'nav-tab-active':''; ?>" href="admin.php?page=wpml-wcml&tab=<?php echo $tax_key; ?>" <?php if(!WCML_Terms::is_fully_translated($tax_key)): ?>title="<?php esc_attr_e('You have untranslated terms!', 'wpml-wcml'); ?>"<?php endif;?>>
43
  <?php echo $tax->labels->name ?>
44
  <?php if(!WCML_Terms::is_fully_translated($tax_key)): ?>
45
  &nbsp;<i class="icon-warning-sign"></i>
@@ -47,7 +47,7 @@ if(isset($_GET['tab'])){
47
  </a>
48
  <?php endforeach; ?>
49
  <?php foreach($all_products_taxonomies as $tax_key => $tax): if(!$sitepress->is_translated_taxonomy($tax_key) || $tax_key == 'product_type') continue; ?>
50
- <a class="js-tax-tab-<?php echo $tax_key ?> nav-tab <?php echo (isset($_GET['tab']) && $_GET['tab'] == $tax_key)?'nav-tab-active':''; ?>" href="admin.php?page=wpml-wcml&tab=<?php echo $tax_key; ?>" <?php if(!WCML_Terms::is_fully_translated($tax_key)): ?>title="<?php esc_attr_e('You have untranslated terms!', 'wpml-wcml'); ?>"<?php endif;?>>
51
  <?php echo $tax->labels->name ?>
52
  <?php if(!WCML_Terms::is_fully_translated($tax_key)): ?>
53
  &nbsp;<i class="icon-warning-sign"></i>
34
  <h2><?php _e('WooCommerce Multilingual', 'wpml-wcml') ?></h2>
35
 
36
  <?php if(current_user_can('wpml_manage_woocommerce_multilingual')): ?>
37
+ <a class="nav-tab <?php echo $current_tab == 'settings' ?'nav-tab-active':''; ?>" href="<?php echo admin_url('admin.php?page=wpml-wcml'); ?>"><?php _e('General settings', 'wpml-wcml') ?></a>
38
  <?php endif; ?>
39
+ <a class="nav-tab <?php echo $current_tab == 'products' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url('admin.php?page=wpml-wcml&tab=products'); ?>"><?php _e('Products', 'wpml-wcml') ?></a>
40
  <?php if( current_user_can('wpml_operate_woocommerce_multilingual')): ?>
41
  <?php foreach($products_and_variation_taxonomies as $tax_key => $tax): if(!$sitepress->is_translated_taxonomy($tax_key)) continue; ?>
42
+ <a class="nav-tab <?php echo (isset($_GET['tab']) && $_GET['tab'] == $tax_key)?'nav-tab-active':''; ?>" href="<?php echo admin_url('admin.php?page=wpml-wcml&tab='.$tax_key); ?>" <?php if(!WCML_Terms::is_fully_translated($tax_key)): ?>title="<?php esc_attr_e('You have untranslated terms!', 'wpml-wcml'); ?>"<?php endif;?>>
43
  <?php echo $tax->labels->name ?>
44
  <?php if(!WCML_Terms::is_fully_translated($tax_key)): ?>
45
  &nbsp;<i class="icon-warning-sign"></i>
47
  </a>
48
  <?php endforeach; ?>
49
  <?php foreach($all_products_taxonomies as $tax_key => $tax): if(!$sitepress->is_translated_taxonomy($tax_key) || $tax_key == 'product_type') continue; ?>
50
+ <a class="js-tax-tab-<?php echo $tax_key ?> nav-tab <?php echo (isset($_GET['tab']) && $_GET['tab'] == $tax_key)?'nav-tab-active':''; ?>" href="<?php echo admin_url('admin.php?page=wpml-wcml&tab='.$tax_key); ?>" <?php if(!WCML_Terms::is_fully_translated($tax_key)): ?>title="<?php esc_attr_e('You have untranslated terms!', 'wpml-wcml'); ?>"<?php endif;?>>
51
  <?php echo $tax->labels->name ?>
52
  <?php if(!WCML_Terms::is_fully_translated($tax_key)): ?>
53
  &nbsp;<i class="icon-warning-sign"></i>
menu/plugins.php CHANGED
@@ -2,7 +2,7 @@
2
  <div class="wrap">
3
  <div id="icon-wpml" class="icon32"><br /></div>
4
  <h2><?php _e('WooCommerce Multilingual', 'wpml-wcml') ?></h2>
5
- <a class="nav-tab nav-tab-active" href="admin.php?page=wpml-wcml"><?php _e('Required plugins', 'wpml-wcml') ?></a>
6
  <div class="wcml_wrap">
7
  <div class="wcml-section">
8
  <div class="wcml-section-header">
2
  <div class="wrap">
3
  <div id="icon-wpml" class="icon32"><br /></div>
4
  <h2><?php _e('WooCommerce Multilingual', 'wpml-wcml') ?></h2>
5
+ <a class="nav-tab nav-tab-active" href="<?php echo admin_url('admin.php?page=wpml-wcml'); ?>"><?php _e('Required plugins', 'wpml-wcml') ?></a>
6
  <div class="wcml_wrap">
7
  <div class="wcml-section">
8
  <div class="wcml-section-header">
menu/sub/currency-switcher-options.php CHANGED
@@ -55,6 +55,17 @@ $currency_switcher_style = isset($settings['currency_switcher_style'])?$settings
55
  </li>
56
  </ul>
57
  </div>
 
 
 
 
 
 
 
 
 
 
 
58
  <div class="wcml-section-content-inner">
59
  <h4><?php _e('Available parameters', 'wpml-wcml'); ?></h4>
60
  <span class="explanation-text"><?php _e('%name%, %symbol%, %code%', 'wpml-wcml'); ?></span>
55
  </li>
56
  </ul>
57
  </div>
58
+ <div class="wcml-section-content-inner">
59
+ <h4><?php _e('Visibility', 'wpml-wcml'); ?></h4>
60
+ <ul class="wcml_curr_visibility">
61
+ <li>
62
+ <label>
63
+ <input type="checkbox" name="currency_switcher_product_visibility" value="1" <?php echo checked( 1, isset($settings['currency_switcher_product_visibility'])?$settings['currency_switcher_product_visibility']:1 ) ?>>
64
+ <?php echo __('Show a currency selector on the product page template', 'wpml-wcml') ?>
65
+ </label>
66
+ </li>
67
+ </ul>
68
+ </div>
69
  <div class="wcml-section-content-inner">
70
  <h4><?php _e('Available parameters', 'wpml-wcml'); ?></h4>
71
  <span class="explanation-text"><?php _e('%name%, %symbol%, %code%', 'wpml-wcml'); ?></span>
menu/sub/product-data.php CHANGED
@@ -33,7 +33,7 @@ $button_labels = array(
33
  <thead>
34
  <tr>
35
  <th scope="col"><?php _e('Language', 'wpml-wcml') ?></th>
36
- <?php $product_contents_labels = $woocommerce_wpml->products->get_product_contents_labels($product_id); ?>
37
  <?php foreach ($product_contents_labels as $product_content) : ?>
38
  <th scope="col"><?php echo $product_content; ?></th>
39
  <?php endforeach; ?>
@@ -74,15 +74,15 @@ $button_labels = array(
74
  <tr rel="<?php echo $key; ?>">
75
  <td>
76
  <?php echo $lang; ?>
77
- <?php if($default_language == $key){ ?>
78
  <a class="edit-translation-link" title="<?php __("edit product", "wpml-wcml") ?>" href="<?php echo get_edit_post_link($product_id); ?>"><i class="icon-edit"></i></a>
79
- <?php }else{ ?>
80
  <input type="hidden" class="icl_language" value="<?php echo $key ?>" />
81
  <input type="hidden" name="end_duplication[<?php echo $product_id ?>][<?php echo $key ?>]" value="<?php echo !intval($is_duplicate_product) ?>" />
82
  <?php $button_label = isset($product_translations[$key]) ? $button_labels['update'] : $button_labels['save'] ;?>
83
  <input type="submit" name="product#<?php echo $product_id ?>#<?php echo $key ?>" disabled value="<?php echo $button_label ?>" class="button-secondary wcml_update">
84
  <span class="wcml_spinner spinner"></span>
85
- <?php } ?>
86
  </td>
87
  <?php
88
  if(isset($product_translations[$key])){
@@ -117,28 +117,48 @@ $button_labels = array(
117
 
118
  if(!$woocommerce_wpml->products->check_custom_field_is_single_value($product_id,$product_content)){
119
  echo $woocommerce_wpml->products->custom_box($product_id,$product_content,$trn_contents,$key,$lang,$is_duplicate_product);
120
- }else if(is_array($trn_contents)): ?>
121
- <?php if(in_array($product_content, array('_file_paths'))): ?>
122
- <?php
123
- $file_paths = '';
124
  foreach($trn_contents as $trn_content){
125
  $file_paths = $file_paths ? $file_paths . "\n" .$trn_content : $trn_content;
126
- } ?>
127
- <?php if($default_language == $key): ?>
128
- <textarea value="<?php echo $file_paths; ?>" disabled="disabled"><?php echo $file_paths; ?></textarea>
129
- <?php else: ?>
130
- <textarea value="<?php echo $file_paths; ?>" name='<?php echo $product_content.'_'.$key ?>' class="wcml_file_paths_textarea<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>><?php echo $file_paths; ?></textarea>
131
- <button type="button" class="button-secondary wcml_file_paths<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>><?php _e('Choose a file', 'wpml-wcml') ?></button>
132
- <?php endif;?>
 
 
 
 
133
  <?php else: ?>
134
- <?php foreach ($trn_contents as $tax_key=>$trn_content) : ?>
 
 
 
 
 
 
135
  <?php if($default_language == $key): ?>
136
- <textarea rows="1" disabled="disabled"><?php echo $trn_content; ?></textarea>
137
  <?php else: ?>
138
- <input class="<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" type="text" name="<?php echo $product_content.'_'.$key.'['.$tax_key.']'; ?>" value="<?php echo $trn_content ?>" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?> /><br>
139
  <?php endif;?>
140
- <?php endforeach; ?>
141
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
142
  <?php elseif(in_array($product_content,array('content','excerpt'))): ?>
143
  <?php if($default_language == $key): ?>
144
  <button type="button" class="button-secondary wcml_edit_content origin_content"><?php _e('Show content', 'wpml-wcml') ?></button>
@@ -215,7 +235,7 @@ $button_labels = array(
215
  <button type="button" class="button-secondary wcml_file_paths<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>><?php _e('Choose a file', 'wpml-wcml') ?></button>
216
  <?php else: ?>
217
  <?php if($default_language == $key): ?>
218
- <textarea rows="1" disabled="disabled"><?php echo $trn_contents; ?></textarea><br>
219
  <?php else: ?>
220
  <textarea class="<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" name="<?php echo $product_content.'_'.$key; ?>" rows="2" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?> ><?php echo $trn_contents; ?></textarea>
221
  <?php endif;?>
33
  <thead>
34
  <tr>
35
  <th scope="col"><?php _e('Language', 'wpml-wcml') ?></th>
36
+ <?php $product_contents_labels = $woocommerce_wpml->products->get_product_contents_labels($product_id);?>
37
  <?php foreach ($product_contents_labels as $product_content) : ?>
38
  <th scope="col"><?php echo $product_content; ?></th>
39
  <?php endforeach; ?>
74
  <tr rel="<?php echo $key; ?>">
75
  <td>
76
  <?php echo $lang; ?>
77
+ <?php if($default_language == $key): ?>
78
  <a class="edit-translation-link" title="<?php __("edit product", "wpml-wcml") ?>" href="<?php echo get_edit_post_link($product_id); ?>"><i class="icon-edit"></i></a>
79
+ <?php else: ?>
80
  <input type="hidden" class="icl_language" value="<?php echo $key ?>" />
81
  <input type="hidden" name="end_duplication[<?php echo $product_id ?>][<?php echo $key ?>]" value="<?php echo !intval($is_duplicate_product) ?>" />
82
  <?php $button_label = isset($product_translations[$key]) ? $button_labels['update'] : $button_labels['save'] ;?>
83
  <input type="submit" name="product#<?php echo $product_id ?>#<?php echo $key ?>" disabled value="<?php echo $button_label ?>" class="button-secondary wcml_update">
84
  <span class="wcml_spinner spinner"></span>
85
+ <?php endif; ?>
86
  </td>
87
  <?php
88
  if(isset($product_translations[$key])){
117
 
118
  if(!$woocommerce_wpml->products->check_custom_field_is_single_value($product_id,$product_content)){
119
  echo $woocommerce_wpml->products->custom_box($product_id,$product_content,$trn_contents,$key,$lang,$is_duplicate_product);
120
+ }else if(in_array($product_content, array('_file_paths'))): ?>
121
+ <?php
122
+ $file_paths = '';
123
+ if( is_array($trn_contents) ){
124
  foreach($trn_contents as $trn_content){
125
  $file_paths = $file_paths ? $file_paths . "\n" .$trn_content : $trn_content;
126
+ }
127
+ } ?>
128
+ <?php if($default_language == $key): ?>
129
+ <textarea value="<?php echo $file_paths; ?>" disabled="disabled"><?php echo $file_paths; ?></textarea>
130
+ <?php else: ?>
131
+ <textarea value="<?php echo $file_paths; ?>" name='<?php echo $product_content.'_'.$key ?>' class="wcml_file_paths_textarea<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>><?php echo $file_paths; ?></textarea>
132
+ <button type="button" class="button-secondary wcml_file_paths<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>><?php _e('Choose a file', 'wpml-wcml') ?></button>
133
+ <?php endif;?>
134
+ <?php elseif($product_content == 'title'): ?>
135
+ <?php if($default_language == $key): ?>
136
+ <textarea rows="1" disabled="disabled"><?php echo $trn_contents['title']; ?></textarea><br>
137
  <?php else: ?>
138
+ <textarea class="<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" name="<?php echo $product_content.'_'.$key; ?>" rows="2" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?> ><?php echo $trn_contents['title']; ?></textarea>
139
+ <?php endif;?>
140
+ <div class="edit_slug_block">
141
+ <?php $hide = !$trn_contents['name'] ? 'hidden' : ''; ?>
142
+ <a href="javascript:void(0)" class="edit_slug_show_link <?php echo $hide; ?>"><?php $default_language == $key ? _e('Show slug', 'wpml-wcml') : _e('Edit slug', 'wpml-wcml') ?></a>
143
+ <a href="javascript:void(0)" class="edit_slug_hide_link <?php echo $hide; ?>"><?php _e('Hide', 'wpml-wcml') ?></a>
144
+ </br>
145
  <?php if($default_language == $key): ?>
146
+ <input type="text" value="<?php echo $trn_contents['name']; ?>" class="edit_slug_input" disabled="disabled" />
147
  <?php else: ?>
148
+ <input type="text" value="<?php echo $trn_contents['name']; ?>" class="edit_slug_input <?php echo $hide; ?>" name="<?php echo 'post_name_'.$key; ?>" <?php echo $hide?'disabled="disabled"':''; ?> />
149
  <?php endif;?>
150
+ <?php if(!$trn_contents['name']): ?>
151
+ <span class="edit_slug_warning"><?php _e('Please save translation before edit slug', 'wpml-wcml') ?></span>
152
+ <?php endif;?>
153
+ </div>
154
+ <?php elseif(is_array($trn_contents)): ?>
155
+ <?php foreach ($trn_contents as $tax_key=>$trn_content) : ?>
156
+ <?php if($default_language == $key): ?>
157
+ <textarea rows="1" disabled="disabled"><?php echo $trn_content; ?></textarea>
158
+ <?php else: ?>
159
+ <input class="<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" type="text" name="<?php echo $product_content.'_'.$key.'['.$tax_key.']'; ?>" value="<?php echo $trn_content ?>" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?> /><br>
160
+ <?php endif;?>
161
+ <?php endforeach; ?>
162
  <?php elseif(in_array($product_content,array('content','excerpt'))): ?>
163
  <?php if($default_language == $key): ?>
164
  <button type="button" class="button-secondary wcml_edit_content origin_content"><?php _e('Show content', 'wpml-wcml') ?></button>
235
  <button type="button" class="button-secondary wcml_file_paths<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?>><?php _e('Choose a file', 'wpml-wcml') ?></button>
236
  <?php else: ?>
237
  <?php if($default_language == $key): ?>
238
+ <textarea rows="1" disabled="disabled"><?php echo $trn_contents; ?></textarea><br>
239
  <?php else: ?>
240
  <textarea class="<?php if($is_duplicate_product): ?> js-dup-disabled<?php endif;?>" name="<?php echo $product_content.'_'.$key; ?>" rows="2" placeholder="<?php esc_attr_e('Enter translation', 'wpml-wcml') ?>"<?php if($is_duplicate_product): ?> disabled="disabled"<?php endif;?> ><?php echo $trn_contents; ?></textarea>
241
  <?php endif;?>
menu/sub/products.php CHANGED
@@ -3,7 +3,7 @@ $pn = isset($_GET['paged'])?$_GET['paged']:1;
3
  $lm = (isset($_GET['lm']) && $_GET['lm'] > 0)?$_GET['lm']:20;
4
 
5
  $search = false;
6
- $pagination_url = 'admin.php?page=wpml-wcml&tab=products&paged=';
7
  $translator_id = false;
8
 
9
  if(isset($_GET['prid'])){
@@ -44,7 +44,7 @@ if(!isset($products) && isset($_GET['s']) && isset($_GET['cat']) && isset($_GET[
44
  $products = $products_data['products'];
45
  $products_count = $products_data['count'];
46
  $search = true;
47
- $pagination_url = 'admin.php?page=wpml-wcml&tab=products&s='.$_GET['s'].'&cat='.$_GET['cat'].'&trst='.$_GET['trst'].'&st='.$_GET['st'].'&slang='.$_GET['slang'].'&paged=';
48
  }
49
 
50
 
3
  $lm = (isset($_GET['lm']) && $_GET['lm'] > 0)?$_GET['lm']:20;
4
 
5
  $search = false;
6
+ $pagination_url = admin_url('admin.php?page=wpml-wcml&tab=products&paged=');
7
  $translator_id = false;
8
 
9
  if(isset($_GET['prid'])){
44
  $products = $products_data['products'];
45
  $products_count = $products_data['count'];
46
  $search = true;
47
+ $pagination_url = admin_url('admin.php?page=wpml-wcml&tab=products&s='.$_GET['s'].'&cat='.$_GET['cat'].'&trst='.$_GET['trst'].'&st='.$_GET['st'].'&slang='.$_GET['slang'].'&paged=');
48
  }
49
 
50
 
menu/sub/settings.php CHANGED
@@ -345,31 +345,32 @@ if( ( !WPML_SUPPORT_STRINGS_IN_DIFF_LANG && $default_language != 'en' && ( $site
345
  </h3>
346
  </div>
347
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" id="wcml_mc_options">
348
- <div class="wcml-section-content">
349
-
350
  <?php wp_nonce_field('wcml_mc_options', 'wcml_nonce'); ?>
351
-
352
  <ul id="wcml_mc_options_block">
353
-
354
  <li>
355
  <ul id="multi_currency_option_select">
356
  <li>
357
- <input type="radio" name="multi_currency" id="multi_currency_disabled" value="<?php echo WCML_MULTI_CURRENCIES_DISABLED ?>" <?php
358
  echo checked($woocommerce_wpml->settings['enable_multi_currency'], WCML_MULTI_CURRENCIES_DISABLED) ?> />
359
  <label for="multi_currency_disabled"><?php _e("No multi-currency.",'wpml-wcml'); ?></label>
360
  </li>
361
  <li>
362
- <input type="radio" name="multi_currency" id="multi_currency_independent" value="<?php echo WCML_MULTI_CURRENCIES_INDEPENDENT ?>" <?php
363
  echo checked($woocommerce_wpml->settings['enable_multi_currency'], WCML_MULTI_CURRENCIES_INDEPENDENT) ?> />
364
- <label for="multi_currency_independent">
365
- <?php _e("Multiple currencies, independent of languages.",'wpml-wcml'); ?>
366
  &nbsp;
367
  <a href=" <?php echo $woocommerce_wpml->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/','multi-currency-support-woocommerce','documentation') ?>"><?php _e('Learn more', 'wpl-wcml') ?></a>.
368
- </label>
369
  </li>
370
  </ul>
371
  </li>
372
  </ul>
 
 
373
 
374
 
375
 
@@ -411,7 +412,7 @@ if( ( !WPML_SUPPORT_STRINGS_IN_DIFF_LANG && $default_language != 'en' && ( $site
411
  <?php
412
  unset($wc_currencies[$wc_currency]);
413
  $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
414
- foreach ($currencies as $code => $currency) :
415
  switch($currency['position']){
416
  case 'left': $positioned_price = sprintf('%s99.99', get_woocommerce_currency_symbol($code)); break;
417
  case 'right': $positioned_price = sprintf('99.99%s', get_woocommerce_currency_symbol($code)); break;
@@ -595,24 +596,15 @@ if( ( !WPML_SUPPORT_STRINGS_IN_DIFF_LANG && $default_language != 'en' && ( $site
595
  ", $default_language));
596
 
597
  if($posts){
598
- $wcml_legacy_remove_custom_rates_nonce = wp_create_nonce( 'legacy_remove_custom_rates' );
599
  echo "<script>
600
  function wcml_remove_custom_rates(post_id, el){
601
  jQuery.ajax({
602
  type: 'post',
603
  dataType: 'json',
604
  url: ajaxurl,
605
- data: {
606
- action: 'legacy_remove_custom_rates',
607
- 'post_id': post_id,
608
- wcml_nonce: '".$wcml_legacy_remove_custom_rates_nonce."'
609
- },
610
- success: function(response){
611
- if(typeof response.error !== 'undefined'){
612
- alert(response.error);
613
- }else{
614
- el.parent().parent().fadeOut(function(){ jQuery(this).remove()});
615
- }
616
  }
617
  })
618
  return false;
@@ -671,12 +663,17 @@ if( ( !WPML_SUPPORT_STRINGS_IN_DIFF_LANG && $default_language != 'en' && ( $site
671
  echo '</tbody>';
672
  echo '</table>';
673
  echo '<p class="button-wrap"><input class="button-secondary" type="submit" value="' . esc_attr__('Update', 'wpml-wcml') . '" /></p>';
674
- echo '<input type="hidden" name="wcml_nonce" value="'. wp_create_nonce('legacy_update_custom_rates') .'" />';
675
  echo '</form>';
676
 
677
 
678
  }
679
- ?>
 
 
 
 
 
 
680
  <p class="button-wrap general_option_btn">
681
  <input type='submit' name="wcml_mc_options" value='<?php _e('Save', 'wpml-wcml'); ?>' class='button-secondary' />
682
  <?php wp_nonce_field('wcml_mc_options', 'wcml_mc_options_nonce'); ?>
@@ -691,6 +688,6 @@ if( ( !WPML_SUPPORT_STRINGS_IN_DIFF_LANG && $default_language != 'en' && ( $site
691
  <input type="hidden" id="wcml_warn_message" value="<?php esc_attr_e('The changes you made will be lost if you navigate away from this page.','wpml-wcml');?>"/>
692
  <input type="hidden" id="wcml_warn_disable_language_massage" value="<?php esc_attr_e('At least one currency must be enabled for this language!','wpml-wcml');?>"/>
693
  <div class="troubleshoot_link_block">
694
- <a href="admin.php?page=<?php echo basename(WCML_PLUGIN_PATH) ?>/menu/sub/troubleshooting.php"><?php _e('Troubleshooting page','wpml-wcml'); ?></a>
695
  </div>
696
  <div class="clear"></div>
345
  </h3>
346
  </div>
347
  <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>" id="wcml_mc_options">
348
+ <div class="wcml-section-content">
 
349
  <?php wp_nonce_field('wcml_mc_options', 'wcml_nonce'); ?>
350
+
351
  <ul id="wcml_mc_options_block">
352
+
353
  <li>
354
  <ul id="multi_currency_option_select">
355
  <li>
356
+ <input type="radio" name="multi_currency" id="multi_currency_disabled" value="<?php echo WCML_MULTI_CURRENCIES_DISABLED ?>" <?php
357
  echo checked($woocommerce_wpml->settings['enable_multi_currency'], WCML_MULTI_CURRENCIES_DISABLED) ?> />
358
  <label for="multi_currency_disabled"><?php _e("No multi-currency.",'wpml-wcml'); ?></label>
359
  </li>
360
  <li>
361
+ <input type="radio" name="multi_currency" id="multi_currency_independent" value="<?php echo WCML_MULTI_CURRENCIES_INDEPENDENT ?>" <?php
362
  echo checked($woocommerce_wpml->settings['enable_multi_currency'], WCML_MULTI_CURRENCIES_INDEPENDENT) ?> />
363
+ <label for="multi_currency_independent">
364
+ <?php _e("Multiple currencies, independent of languages.",'wpml-wcml'); ?>
365
  &nbsp;
366
  <a href=" <?php echo $woocommerce_wpml->generate_tracking_link('http://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/','multi-currency-support-woocommerce','documentation') ?>"><?php _e('Learn more', 'wpl-wcml') ?></a>.
367
+ </label>
368
  </li>
369
  </ul>
370
  </li>
371
  </ul>
372
+
373
+
374
 
375
 
376
 
412
  <?php
413
  unset($wc_currencies[$wc_currency]);
414
  $currencies = $woocommerce_wpml->multi_currency_support->get_currencies();
415
+ foreach ($currencies as $code => $currency) :
416
  switch($currency['position']){
417
  case 'left': $positioned_price = sprintf('%s99.99', get_woocommerce_currency_symbol($code)); break;
418
  case 'right': $positioned_price = sprintf('99.99%s', get_woocommerce_currency_symbol($code)); break;
596
  ", $default_language));
597
 
598
  if($posts){
 
599
  echo "<script>
600
  function wcml_remove_custom_rates(post_id, el){
601
  jQuery.ajax({
602
  type: 'post',
603
  dataType: 'json',
604
  url: ajaxurl,
605
+ data: {action: 'legacy_remove_custom_rates', 'post_id': post_id},
606
+ success: function(){
607
+ el.parent().parent().fadeOut(function(){ jQuery(this).remove()});
 
 
 
 
 
 
 
 
608
  }
609
  })
610
  return false;
663
  echo '</tbody>';
664
  echo '</table>';
665
  echo '<p class="button-wrap"><input class="button-secondary" type="submit" value="' . esc_attr__('Update', 'wpml-wcml') . '" /></p>';
 
666
  echo '</form>';
667
 
668
 
669
  }
670
+ ?>
671
+ <ul id="display_custom_prices_select">
672
+ <li>
673
+ <input type="checkbox" name="display_custom_prices" id="display_custom_prices" value="1" <?php echo checked( 1, $woocommerce_wpml->settings['display_custom_prices']) ?> >
674
+ <label for="display_custom_prices"><?php _e('Show only products with custom prices in secondary currencies', 'wpml-wcml'); ?></label>
675
+ </li>
676
+ </ul>
677
  <p class="button-wrap general_option_btn">
678
  <input type='submit' name="wcml_mc_options" value='<?php _e('Save', 'wpml-wcml'); ?>' class='button-secondary' />
679
  <?php wp_nonce_field('wcml_mc_options', 'wcml_mc_options_nonce'); ?>
688
  <input type="hidden" id="wcml_warn_message" value="<?php esc_attr_e('The changes you made will be lost if you navigate away from this page.','wpml-wcml');?>"/>
689
  <input type="hidden" id="wcml_warn_disable_language_massage" value="<?php esc_attr_e('At least one currency must be enabled for this language!','wpml-wcml');?>"/>
690
  <div class="troubleshoot_link_block">
691
+ <a href="<?php echo admin_url('admin.php?page='.basename(WCML_PLUGIN_PATH) .'/menu/sub/troubleshooting.php'); ?>"><?php _e('Troubleshooting page','wpml-wcml'); ?></a>
692
  </div>
693
  <div class="clear"></div>
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
- === WooCommerce Multilingual - run WooCommerce with WPML ===
2
  Contributors: AmirHelzer, dominykasgel, dgwatkins, adelval
3
  Donate link: http://wpml.org/documentation/related-projects/woocommerce-multilingual/
4
  Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multilingual, e-shop, shop
5
  License: GPLv2
6
  Requires at least: 3.0
7
  Tested up to: 4.2
8
- Stable tag: 3.5.5
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
@@ -78,6 +78,21 @@ In order for the checkout and store pages to appear translated, you need to crea
78
 
79
  == Changelog ==
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  = 3.5.5 =
82
  * Bug fixed: Custom attributes were disappearing after updating a product in the WooCommerce native product editor
83
  * Tested compatibility with WordPress 4.2
1
+ === WooCommerce Multilingual - run WooCommerce with WPML ===
2
  Contributors: AmirHelzer, dominykasgel, dgwatkins, adelval
3
  Donate link: http://wpml.org/documentation/related-projects/woocommerce-multilingual/
4
  Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multilingual, e-shop, shop
5
  License: GPLv2
6
  Requires at least: 3.0
7
  Tested up to: 4.2
8
+ Stable tag: 3.6
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
78
 
79
  == Changelog ==
80
 
81
+ = 3.6 =
82
+ * Added the ability to edit the slugs of the translated products in the products editor
83
+ * Added the option to show only products with custom prices on the front end
84
+ * Performance improvements: fewer db queries, caching. Up to 40% faster on large sites.
85
+ * Support for the 'lang' parameter in WooCommerce REST API calls
86
+ * Option to hide the default currency selector on the product page
87
+ * Bug fix: Fixed a design issue on the 'connect with translation' pop-up on products.
88
+ * Bug fix: Accessing the source content in the WooCommerce Multilingual product translation content editor was not possible sometimes.
89
+ * Bug fix: 'Invisible' products were showing as links in the cart instead of just names.
90
+ * Bug fix: The cart_widget.js code was always loaded.
91
+ * Bug fix: Screen Options & Check All not working on WooCommerce Orders page
92
+ * Bug fix: Sometimes the IPN Url sent to Paypal was wrong causing a 404 error after the payment was complete
93
+ * Bug fix: Translated endpoint pages were sometimes returning 404
94
+ * Bug fix: When using a default language different than English, the product permalink base was not in English.
95
+
96
  = 3.5.5 =
97
  * Bug fixed: Custom attributes were disappearing after updating a product in the WooCommerce native product editor
98
  * Tested compatibility with WordPress 4.2
woocommerce_wpml.class.php CHANGED
@@ -15,7 +15,7 @@ class woocommerce_wpml {
15
  add_action('init', array($this, 'init'),2);
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
 
@@ -33,7 +33,7 @@ class woocommerce_wpml {
33
 
34
  global $sitepress,$pagenow;
35
 
36
- if($this->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT ){
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';
@@ -41,7 +41,8 @@ class woocommerce_wpml {
41
  }else{
42
  add_shortcode('currency_switcher', '__return_empty_string');
43
  }
44
-
 
45
  $this->products = new WCML_Products;
46
  $this->store = new WCML_Store_Pages;
47
  $this->emails = new WCML_Emails;
@@ -51,19 +52,23 @@ class woocommerce_wpml {
51
  $this->compatibility = new WCML_Compatibility();
52
  $this->strings = new WCML_WC_Strings;
53
  $this->currency_switcher = new WCML_CurrencySwitcher;
54
-
 
55
 
56
  if(isset($_GET['page']) && $_GET['page'] == 'wc-reports'){
57
  require_once WCML_PLUGIN_PATH . '/inc/reports.class.php';
58
  $this->reports = new WCML_Reports;
59
  }
60
 
61
- include WCML_PLUGIN_PATH . '/inc/woocommerce-2.0-backward-compatibility.php';
 
62
 
63
  new WCML_Ajax_Setup;
64
 
65
  new WCML_Requests;
66
 
 
 
67
  $this->install();
68
 
69
  add_action('init', array($this,'load_locale'));
@@ -157,7 +162,8 @@ class woocommerce_wpml {
157
  'enable_multi_currency' => WCML_MULTI_CURRENCIES_DISABLED,
158
  'dismiss_doc_main' => 0,
159
  'trnsl_interface' => 1,
160
- 'currency_options' => array()
 
161
  );
162
 
163
  if(empty($this->settings)){
@@ -201,49 +207,52 @@ class woocommerce_wpml {
201
  load_plugin_textdomain('wpml-wcml', false, WCML_LOCALE_PATH);
202
  }
203
 
204
- function install()
205
- {
206
  global $wpdb;
207
-
208
- if (empty($this->settings['set_up'])) { // from 3.2
209
-
210
  if ($this->settings['is_term_order_synced'] !== 'yes') {
211
  //global term ordering resync when moving to >= 3.3.x
212
  add_action('init', array($this->terms, 'sync_term_order_globally'), 20);
213
  }
214
 
215
- if (!get_option('wcml_custom_attr_translations')) {
216
- add_option('wcml_custom_attr_translations', array());
217
  }
218
 
219
- if (!isset($this->settings['wc_admin_options_saved'])) {
220
  $this->handle_admin_texts();
221
  $this->settings['wc_admin_options_saved'] = 1;
222
  }
223
 
224
- if (!isset($this->settings['trnsl_interface'])) {
225
  $this->settings['trnsl_interface'] = 1;
226
  }
227
-
228
- if (!isset($this->settings['products_sync_date'])) {
229
  $this->settings['products_sync_date'] = 1;
230
  }
231
 
232
- if (!isset($this->settings['products_sync_order'])) {
233
  $this->settings['products_sync_order'] = 1;
234
  }
235
 
 
 
 
 
236
  self::set_up_capabilities();
237
-
238
  $this->set_language_information();
239
-
240
  $this->settings['set_up'] = 1;
241
  $this->update_settings();
242
 
243
 
244
  }
245
 
246
- if (empty($this->settings['downloaded_translations_for_wc'])) { //from 3.3.3
247
  $this->download_woocommerce_translations_for_active_languages();
248
  $this->settings['downloaded_translations_for_wc'] = 1;
249
  $this->update_settings();
@@ -410,7 +419,7 @@ class woocommerce_wpml {
410
  wp_enqueue_style( 'buttons' );
411
  }
412
 
413
- }elseif( $_GET['page'] == 'wpml-translation-management/menu/main.php' ){
414
  wp_register_script('wpml_tm', WCML_PLUGIN_URL . '/assets/js/wpml_tm.js', array('jquery'), WCML_VERSION);
415
  wp_enqueue_script('wpml_tm');
416
  }
15
  add_action('init', array($this, 'init'),2);
16
  add_action('init', array($this, 'load_css_and_js'));
17
 
18
+
19
  add_action('widgets_init', array($this, 'register_widget'));
20
  }
21
 
33
 
34
  global $sitepress,$pagenow;
35
 
36
+ if($this->settings['enable_multi_currency'] == WCML_MULTI_CURRENCIES_INDEPENDENT){
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';
41
  }else{
42
  add_shortcode('currency_switcher', '__return_empty_string');
43
  }
44
+
45
+ $this->endpoints = new WCML_Endpoints;
46
  $this->products = new WCML_Products;
47
  $this->store = new WCML_Store_Pages;
48
  $this->emails = new WCML_Emails;
52
  $this->compatibility = new WCML_Compatibility();
53
  $this->strings = new WCML_WC_Strings;
54
  $this->currency_switcher = new WCML_CurrencySwitcher;
55
+
56
+
57
 
58
  if(isset($_GET['page']) && $_GET['page'] == 'wc-reports'){
59
  require_once WCML_PLUGIN_PATH . '/inc/reports.class.php';
60
  $this->reports = new WCML_Reports;
61
  }
62
 
63
+ include WCML_PLUGIN_PATH . '/inc/woocommerce-2.0-backward-compatibility.php';
64
+ include WCML_PLUGIN_PATH . '/inc/wc-rest-api-support.php';
65
 
66
  new WCML_Ajax_Setup;
67
 
68
  new WCML_Requests;
69
 
70
+ new WCML_WooCommerce_Rest_API_Support;
71
+
72
  $this->install();
73
 
74
  add_action('init', array($this,'load_locale'));
162
  'enable_multi_currency' => WCML_MULTI_CURRENCIES_DISABLED,
163
  'dismiss_doc_main' => 0,
164
  'trnsl_interface' => 1,
165
+ 'currency_options' => array(),
166
+ 'currency_switcher_product_visibility' => 1
167
  );
168
 
169
  if(empty($this->settings)){
207
  load_plugin_textdomain('wpml-wcml', false, WCML_LOCALE_PATH);
208
  }
209
 
210
+ function install(){
 
211
  global $wpdb;
212
+
213
+ if(empty($this->settings['set_up'])){ // from 3.2
214
+
215
  if ($this->settings['is_term_order_synced'] !== 'yes') {
216
  //global term ordering resync when moving to >= 3.3.x
217
  add_action('init', array($this->terms, 'sync_term_order_globally'), 20);
218
  }
219
 
220
+ if(!get_option('wcml_custom_attr_translations')){
221
+ add_option('wcml_custom_attr_translations',array());
222
  }
223
 
224
+ if(!isset($this->settings['wc_admin_options_saved'])){
225
  $this->handle_admin_texts();
226
  $this->settings['wc_admin_options_saved'] = 1;
227
  }
228
 
229
+ if(!isset($this->settings['trnsl_interface'])){
230
  $this->settings['trnsl_interface'] = 1;
231
  }
232
+
233
+ if(!isset($this->settings['products_sync_date'])){
234
  $this->settings['products_sync_date'] = 1;
235
  }
236
 
237
+ if(!isset($this->settings['products_sync_order'])){
238
  $this->settings['products_sync_order'] = 1;
239
  }
240
 
241
+ if(!isset($this->settings['display_custom_prices'])){
242
+ $this->settings['display_custom_prices'] = 0;
243
+ }
244
+
245
  self::set_up_capabilities();
246
+
247
  $this->set_language_information();
248
+
249
  $this->settings['set_up'] = 1;
250
  $this->update_settings();
251
 
252
 
253
  }
254
 
255
+ if(empty($this->settings['downloaded_translations_for_wc'])){ //from 3.3.3
256
  $this->download_woocommerce_translations_for_active_languages();
257
  $this->settings['downloaded_translations_for_wc'] = 1;
258
  $this->update_settings();
419
  wp_enqueue_style( 'buttons' );
420
  }
421
 
422
+ }elseif( $_GET['page'] == WPML_TM_FOLDER.'/menu/main.php' ){
423
  wp_register_script('wpml_tm', WCML_PLUGIN_URL . '/assets/js/wpml_tm.js', array('jquery'), WCML_VERSION);
424
  wp_enqueue_script('wpml_tm');
425
  }
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.5.5
9
  */
10
 
11
 
12
  if(defined('WCML_VERSION')) return;
13
- define('WCML_VERSION', '3.5.5');
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.6
9
  */
10
 
11
 
12
  if(defined('WCML_VERSION')) return;
13
+ define('WCML_VERSION', '3.6');
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);