Saphali Woocommerce Russian - Version 1.8.0

Version Description

  • , . ., , - , - .
Download this release

Release Info

Developer Saphali
Plugin Icon wp plugin Saphali Woocommerce Russian
Version 1.8.0
Comparing to
See all releases

Code changes from version 1.7.1 to 1.8.0

Files changed (2) hide show
  1. readme.txt +6 -2
  2. saphali-woocommerce-lite.php +183 -22
readme.txt CHANGED
@@ -5,8 +5,8 @@ Plugin URI: http://saphali.com/saphali-woocommerce-plugin-wordpress
5
  Donate link: https://money.yandex.ru/to/410011651211340
6
  Tags: woocommerce, woo commerce russian, russian ruble, ukrainian hryvnia, mod, manadger filds checkout
7
  Requires at least: WP 3.3 or higher & WooCommerce 1.6.6 or higher
8
- Tested up to: 4.8
9
- Stable tag: 1.7.1
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -38,6 +38,7 @@ wp-content/languages/plugins/woocommerce-admin-ru_RU.mo (админ часть),
38
  * Управление количеством колонок в каталоге товаров (Магазин) и категориях.
39
  * Плагин создан с целью упростить разработку интернет-магазинов для российского рынка.
40
  * Плагин не изменяет оригинальные файлы Woocommerce, вы можете обновлять плагин Woocommerce, каждый раз при появлении новых версий!
 
41
 
42
  <strong>ВНИМАНИЕ!</strong>
43
 
@@ -72,6 +73,9 @@ define('SAPHALI_LITE_SYMBOL', 0 );
72
 
73
  == Changelog ==
74
 
 
 
 
75
  = 1.7.1 =
76
  * В версии WC 3.x.x отображение добавленных полей, которые отсутствуют по умолчанию в WC.
77
 
5
  Donate link: https://money.yandex.ru/to/410011651211340
6
  Tags: woocommerce, woo commerce russian, russian ruble, ukrainian hryvnia, mod, manadger filds checkout
7
  Requires at least: WP 3.3 or higher & WooCommerce 1.6.6 or higher
8
+ Tested up to: 4.9
9
+ Stable tag: 1.8.0
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
38
  * Управление количеством колонок в каталоге товаров (Магазин) и категориях.
39
  * Плагин создан с целью упростить разработку интернет-магазинов для российского рынка.
40
  * Плагин не изменяет оригинальные файлы Woocommerce, вы можете обновлять плагин Woocommerce, каждый раз при появлении новых версий!
41
+ * Сопоставление полей с методами оплаты и доставки, напр., будет полезно, если некоторые поля не требуется отображать при оплате каким-то методом доставки и/или оплаты, но нужны в каком-то другом методе доставки или оплаты.
42
 
43
  <strong>ВНИМАНИЕ!</strong>
44
 
73
 
74
  == Changelog ==
75
 
76
+ = 1.8.0 =
77
+ * Добавлен функционал, который позволяет соотнести поле к методам доставки. Напр., будет полезно, если некоторые поля не требуется выводить при оплате каким-то методом доставки, но нужны в каком-то другом методе доставки.
78
+
79
  = 1.7.1 =
80
  * В версии WC 3.x.x отображение добавленных полей, которые отсутствуют по умолчанию в WC.
81
 
saphali-woocommerce-lite.php CHANGED
@@ -3,13 +3,13 @@
3
  Plugin Name: Saphali Woocommerce Russian
4
  Plugin URI: http://saphali.com/saphali-woocommerce-plugin-wordpress
5
  Description: Saphali Woocommerce Russian - это бесплатный вордпресс плагин, который добавляет набор дополнений к интернет-магазину на Woocommerce.
6
- Version: 1.7.1
7
  Author: Saphali
8
  Author URI: http://saphali.com/
9
  Text Domain: saphali-woocommerce-lite
10
  Domain Path: /languages
11
  WC requires at least: 1.6.6
12
- WC tested up to: 3.2.2
13
  */
14
 
15
 
@@ -35,7 +35,7 @@ WC tested up to: 3.2.2
35
 
36
  // Подключение валюты и локализации
37
  define('SAPHALI_PLUGIN_DIR_URL',plugin_dir_url(__FILE__));
38
- define('SAPHALI_LITE_VERSION', '1.7.1' );
39
  define('SAPHALI_PLUGIN_DIR_PATH',plugin_dir_path(__FILE__));
40
  class saphali_lite {
41
  var $email_order_id;
@@ -139,7 +139,7 @@ WC tested up to: 3.2.2
139
  $is_e = true;
140
  if( isset( $errors->errors["required-field"] ) ) {
141
  foreach($errors->errors["required-field"] as $i => $_e) {
142
- if( strpos($_e, strtolower($value["rf"]) ) !== false || strpos($_e, $value["rf"]) !== false ) {
143
  unset($errors->errors["required-field"][$i]);
144
  }
145
  }
@@ -171,6 +171,21 @@ WC tested up to: 3.2.2
171
  $r = ( isset($value["required"]) && $value["required"] );
172
  $keys[ $key ] = array( 'pm' => $value['payment_method'], 'r' => $r, 'rf' => $value["label"], 'type' => $type );
173
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  }
175
  }
176
  $is_e = false;
@@ -204,6 +219,35 @@ WC tested up to: 3.2.2
204
  $is_e = $this->remove_no_valid_filds($key, $value, $errors);
205
  }
206
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  }
208
  }
209
  if($is_e && !version_compare( WOOCOMMERCE_VERSION, '3.0.0', '<' ) ) {
@@ -242,12 +286,28 @@ WC tested up to: 3.2.2
242
  if(isset($value['payment_method']) && !empty($value['payment_method'])) {
243
  $keys[ $key ] = $value['payment_method'];
244
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  }
246
  }
247
  }
248
  ?>
249
  <script>
250
  var $keys = <?php if( isset($keys) ) echo json_encode($keys); else echo '[]'; ?>;
 
251
  function corect_payment_method_filds () {
252
  var selected_p_method = jQuery("input[name=\"payment_method\"]:checked").val();
253
  jQuery.each($keys, function(i,e){
@@ -259,11 +319,28 @@ WC tested up to: 3.2.2
259
  }
260
  });
261
  }
 
 
 
 
 
 
 
 
 
 
262
  jQuery("body").delegate("input[name=\"payment_method\"]", 'click', function(){
263
  corect_payment_method_filds ();
264
  });
 
 
 
 
 
 
265
  jQuery('body').bind('updated_checkout', function() {
266
  corect_payment_method_filds ();
 
267
  });
268
  </script>
269
  <?php
@@ -430,8 +507,19 @@ WC tested up to: 3.2.2
430
  }
431
  public function woocommerce_default_address_fields($locale) {
432
  $fieldss = get_option('woocommerce_saphali_filds_locate');
433
- if(is_array($fieldss))
434
- $locale = $fieldss;
 
 
 
 
 
 
 
 
 
 
 
435
  return $locale;
436
  }
437
  public function woocommerce_get_country_locale($locale) {
@@ -653,13 +741,13 @@ WC tested up to: 3.2.2
653
  $filds = $global_f_checkout_fields;
654
 
655
  if(is_array($filds["billing"])) {
656
- if(!is_array($addFild["billing"])) $addFild["billing"] = array();
657
  if(!is_array($_POST["billing"])) $_POST["billing"] = array();
658
  $filds["billing"] = array_merge($filds["billing"] , $_POST["billing"], $addFild["billing"]);
659
 
660
  foreach($filds["billing"] as $key_post => $value_post) {
661
 
662
- if( !isset($global_f_checkout_fields["billing"][$key_post]['type']) && $filds["billing"][$key_post]['type'] != 'select' && $filds["billing"][$key_post]['type'] != 'checkbox' && $filds["billing"][$key_post]['type'] != 'textarea' ) unset($filds["billing"][$key_post]['type'], $value_post["type"]);
663
 
664
 
665
  if(@$filds["billing"][$key_post]['public'] != 'on') {
@@ -680,8 +768,8 @@ WC tested up to: 3.2.2
680
  }
681
 
682
  }
683
- if(is_array($filds["shipping"])) {
684
- if(!is_array($addFild["shipping"])) $addFild["shipping"] = array();
685
  if(!is_array($_POST["shipping"])) $_POST["shipping"] = array();
686
  $filds["shipping"] = array_merge($filds["shipping"] , $_POST["shipping"], $addFild["shipping"]);
687
  foreach($filds["shipping"] as $key_post => $value_post) {
@@ -703,8 +791,8 @@ WC tested up to: 3.2.2
703
  unset($_POST["shipping"][$key_post]);
704
  }
705
  }
706
- if(is_array($filds["order"])) {
707
- if(!is_array($addFild["order"])) $addFild["order"] = array();
708
  if(!is_array($_POST["order"])) $_POST["order"] = array();
709
  $filds["order"] = array_merge($filds["order"] , $_POST["order"], $addFild["order"]);
710
 
@@ -750,12 +838,12 @@ WC tested up to: 3.2.2
750
  unset($filds_finish_filter["billing"][$v_filt]);
751
  }
752
  }
753
- if(is_array($fild_remove_filter["shipping"])) {
754
  foreach($fild_remove_filter["shipping"] as $v_filt){
755
  unset($filds_finish_filter["shipping"][$v_filt]);
756
  }
757
  }
758
- if(is_array($fild_remove_filter["order"])) {
759
  foreach($fild_remove_filter["order"] as $v_filt){
760
  unset($filds_finish_filter["order"][$v_filt]);
761
  }
@@ -797,6 +885,7 @@ WC tested up to: 3.2.2
797
 
798
  <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
799
  <th width="120px">Метод оплаты</th>
 
800
  <th width="65px">Удалить/До&shy;ба&shy;вить</th>
801
  </tr>
802
  </thead>
@@ -812,6 +901,7 @@ WC tested up to: 3.2.2
812
 
813
  <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
814
  <th width="120px">Метод оплаты</th>
 
815
  <th>Удалить/До&shy;ба&shy;вить</th>
816
  </tr>
817
  </tfoot>
@@ -828,7 +918,10 @@ WC tested up to: 3.2.2
828
 
829
  $public = 'public';
830
  if( !version_compare( WOOCOMMERCE_VERSION, '3.0', '<' ) ) {
831
- if( isset( $checkout_fields["billing"][$key] ) ) $value[$public] = $checkout_fields["billing"][$key][$public];
 
 
 
832
  }
833
  if(isset($checkout_fields["billing"][$key]['payment_method'])) {
834
  $pm_k_remove = array();
@@ -843,6 +936,19 @@ WC tested up to: 3.2.2
843
  }
844
  if( isset( $checkout_fields["billing"][$key] ) ) $value['payment_method'] = $checkout_fields["billing"][$key]['payment_method'];
845
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
846
 
847
  if(empty($value[$public]) && !is_array($checkout_fields["billing"])) $value[$public] = true;
848
  ?>
@@ -884,7 +990,17 @@ WC tested up to: 3.2.2
884
  ?>
885
  </select>
886
  </td>
887
-
 
 
 
 
 
 
 
 
 
 
888
  <td><input rel="sort_order" id="order_count" type="hidden" name="billing[<?php echo $key?>][order]" value="<?php echo $count?>" />
889
  <input type="button" class="button" id="billing_delete" value="Удалить -"/></td>
890
  </tr>
@@ -920,6 +1036,7 @@ WC tested up to: 3.2.2
920
 
921
  <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
922
  <th width="120px">Метод оплаты</th>
 
923
  <th width="65px">Удалить/До&shy;ба&shy;вить</th>
924
  </tr>
925
  </thead>
@@ -934,6 +1051,7 @@ WC tested up to: 3.2.2
934
 
935
  <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
936
  <th width="120px">Метод оплаты</th>
 
937
  <th>Удалить/До&shy;ба&shy;вить</th>
938
  </tr>
939
  </tfoot>
@@ -959,13 +1077,26 @@ WC tested up to: 3.2.2
959
  }
960
  if( isset( $checkout_fields["shipping"][$key] ) ) $value['payment_method'] = $checkout_fields["shipping"][$key]['payment_method'];
961
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
962
  if( empty($value['public']) && !is_array($checkout_fields["shipping"]) ) $value['public'] = true;
963
  ?>
964
  <tr>
965
  <td><input disabled value=<?php echo $key?> type="text" name="shipping[<?php echo $key?>][name]" /></td>
966
- <td><input value='<?php echo $value['label']?>' type="text" name="shipping[<?php echo $key?>][label]" /><input value='<?php echo $value['type']?>' type="hidden" name="shipping[<?php echo $key?>][type]" /></td>
967
  <td><input value='<?php if(isset( $value['placeholder'] )) echo $value['placeholder']; ?>' type="text" name="shipping[<?php echo $key?>][placeholder]" /></td>
968
- <td><input <?php if(isset($value['clear']) && $value['clear']) echo 'checked'?> class="<?php echo $value['clear']?>" type="checkbox" name="shipping[<?php echo $key?>][clear]" /></td>
969
  <td><?php if( isset($value['class']) && is_array($value['class']) ) { foreach($value['class'] as $v_class) { ?>
970
 
971
  <input value='<?php echo $v_class;?>' type="text" name="shipping[<?php echo $key?>][class][]" /> <?php } } else { ?>
@@ -983,6 +1114,16 @@ WC tested up to: 3.2.2
983
  }
984
  ?>
985
  </select>
 
 
 
 
 
 
 
 
 
 
986
  </td>
987
 
988
  <td><input rel="sort_order" id="order_count" type="hidden" name="shipping[<?php echo $key?>][order]" value="<?php echo $count?>" /><input type="button" class="button" id="billing_delete" value="Удалить -"/>
@@ -1150,6 +1291,16 @@ WC tested up to: 3.2.2
1150
  }
1151
  ?>\
1152
  </select>\
 
 
 
 
 
 
 
 
 
 
1153
  </td>';
1154
  obj.html('<td><input value="billing_new_fild'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" type="text" name="billing[new_fild][name][]" /></td><td><input value="" type="text" name="billing[new_fild][label][]" /></td><td><input value="" type="text" name="billing[new_fild][placeholder][]" /></td><td><input type="checkbox" name="billing[new_fild][clear][]" /></td><td><input value="" type="text" name="billing[new_fild][class][]" /></td><td> Select <input type="radio" value="select" name="billing[new_fild][type]"><br>Radio <input type="radio" value="radio" name="billing[new_fild][type]"><br>Checkbox <input type="radio" value="checkbox" name="billing[new_fild][type]"><br> Textarea <input type="radio" value="textarea" name="billing[new_fild][type]"><br> Text <input type="radio" value="" name="billing[new_fild][type]" checked="checked"></td><td><input checked type="checkbox" name="billing[new_fild][required][]" /></td><td><input checked type="checkbox" name="billing[new_fild][public][]" /></td>' + fild_pm + '<td><input id="order_count" rel="sort_order" type="hidden" name="billing[new_fild][order][]" value="'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" /><input type="button" class="button" id="billing_delete" value="Удалить -"/></td>');
1155
  obj.removeClass('nodrop nodrag');
@@ -1167,6 +1318,16 @@ WC tested up to: 3.2.2
1167
  }
1168
  ?>\
1169
  </select>\
 
 
 
 
 
 
 
 
 
 
1170
  </td>';
1171
  obj.html('<td><input value="shipping_new_fild'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" type="text" name="shipping[new_fild][name][]" /></td><td><input value="" type="text" name="shipping[new_fild][label][]" /></td><td><input value="" type="text" name="shipping[new_fild][placeholder][]" /></td><td><input type="checkbox" name="shipping[new_fild][clear][]" /></td><td><input value="" type="text" name="shipping[new_fild][class][]" /></td><td><input checked type="checkbox" name="shipping[new_fild][required][]" /></td><td><input checked type="checkbox" name="shipping[new_fild][public][]" /></td>' + fild_pm + '<td><input id="order_count" rel="sort_order" type="hidden" name="shipping[new_fild][order][]" value="'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" /><input type="button" class="button" id="billing_delete" value="Удалить -"/></td>');
1172
  obj.removeClass('nodrop nodrag');
@@ -1236,15 +1397,15 @@ WC tested up to: 3.2.2
1236
  'description' => ''
1237
  ),
1238
  'billing_city' => array(
1239
- 'label' => __('City', 'woocommerce'),
1240
  'description' => ''
1241
  ),
1242
  'billing_postcode' => array(
1243
- 'label' => __('Postcode', 'woocommerce'),
1244
  'description' => ''
1245
  ),
1246
  'billing_state' => array(
1247
- 'label' => __('State/County', 'woocommerce'),
1248
  'description' => __('Country or state code', 'woocommerce'),
1249
  ),
1250
  'billing_country' => array(
@@ -1473,7 +1634,7 @@ WC tested up to: 3.2.2
1473
  if(isset($fields[$v][$key]["label"]))
1474
  $fields[$v][$key]["label"] = __($value["label"], 'woocommerce');
1475
  if(isset($fields[$v][$key]["placeholder"]))
1476
- $fields[$v][$key]["placeholder"] = __($value["placeholder"], 'saphali-woocommerce-lite');
1477
  }
1478
  return $fields;
1479
  }
3
  Plugin Name: Saphali Woocommerce Russian
4
  Plugin URI: http://saphali.com/saphali-woocommerce-plugin-wordpress
5
  Description: Saphali Woocommerce Russian - это бесплатный вордпресс плагин, который добавляет набор дополнений к интернет-магазину на Woocommerce.
6
+ Version: 1.8.0
7
  Author: Saphali
8
  Author URI: http://saphali.com/
9
  Text Domain: saphali-woocommerce-lite
10
  Domain Path: /languages
11
  WC requires at least: 1.6.6
12
+ WC tested up to: 3.2.5
13
  */
14
 
15
 
35
 
36
  // Подключение валюты и локализации
37
  define('SAPHALI_PLUGIN_DIR_URL',plugin_dir_url(__FILE__));
38
+ define('SAPHALI_LITE_VERSION', '1.8.0' );
39
  define('SAPHALI_PLUGIN_DIR_PATH',plugin_dir_path(__FILE__));
40
  class saphali_lite {
41
  var $email_order_id;
139
  $is_e = true;
140
  if( isset( $errors->errors["required-field"] ) ) {
141
  foreach($errors->errors["required-field"] as $i => $_e) {
142
+ if( strpos($_e, strtolower(__($value["rf"], 'woocommerce')) ) !== false || strpos($_e, __($value["rf"], 'woocommerce')) !== false ) {
143
  unset($errors->errors["required-field"][$i]);
144
  }
145
  }
171
  $r = ( isset($value["required"]) && $value["required"] );
172
  $keys[ $key ] = array( 'pm' => $value['payment_method'], 'r' => $r, 'rf' => $value["label"], 'type' => $type );
173
  }
174
+ if(isset($value['shipping_method'])) {
175
+ $pm_k_remove = array();
176
+ foreach($value['shipping_method'] as $k => $v) {
177
+ if($v === '0') {
178
+ $pm_k_remove[] = $k;
179
+ }
180
+ }
181
+ foreach($pm_k_remove as $k_remove) {
182
+ unset($value['shipping_method'][$k_remove]);
183
+ }
184
+ }
185
+ if(isset($value['shipping_method']) && !empty($value['shipping_method'])) {
186
+ $r = ( isset($value["required"]) && $value["required"] );
187
+ $keys[ $key ] = array( 'pm' => $value['shipping_method'], 'r' => $r, 'rf' => $value["label"], 'type' => $type );
188
+ }
189
  }
190
  }
191
  $is_e = false;
219
  $is_e = $this->remove_no_valid_filds($key, $value, $errors);
220
  }
221
  }
222
+ $s_m = in_array($_POST['shipping_method'], $value["pm"]) || in_array($_POST['shipping_method'][0], $value["pm"]) || in_array( preg_replace('/\:(.*)$/', '', $_POST['shipping_method'][0]), $value["pm"]);
223
+ if( $s_m ) {
224
+ if( empty($_POST[$key])) {
225
+ $is_e = $this->remove_no_valid_filds($key, $value, $errors);
226
+ if( version_compare( WOOCOMMERCE_VERSION, '3.0.0', '<' ) ) {
227
+ if( !version_compare( WOOCOMMERCE_VERSION, '2.6.0', '<' ) )
228
+ $this->comp_woocomerce_mess_error( sprintf( _x( '%s is a required field.', 'FIELDNAME is a required field.', 'woocommerce' ), '<strong>' . $value["rf"] . '</strong>' ) );
229
+ else
230
+ $this->comp_woocomerce_mess_error( '<strong>' . $value["rf"] . '</strong> ' . __( 'is a required field.', 'woocommerce' ) );
231
+ } else {
232
+ switch ($value["type"]) {
233
+ case 'shipping' :
234
+ /* translators: %s: field name */
235
+ $field_label = __( 'Shipping %s', 'woocommerce' );
236
+ break;
237
+ case 'billing' :
238
+ /* translators: %s: field name */
239
+ $field_label = __( 'Billing %s', 'woocommerce' );
240
+ break;
241
+ }
242
+ $fl = function_exists('mb_strtolower') ? mb_strtolower( sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . $value["rf"] . '</strong>' ) ) : sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . $value["rf"] . '</strong>' );
243
+ $this->comp_woocomerce_mess_error( sprintf( $field_label, $fl ) );
244
+ }
245
+ }
246
+ } else {
247
+ if( empty($_POST[$key])) {
248
+ $is_e = $this->remove_no_valid_filds($key, $value, $errors);
249
+ }
250
+ }
251
  }
252
  }
253
  if($is_e && !version_compare( WOOCOMMERCE_VERSION, '3.0.0', '<' ) ) {
286
  if(isset($value['payment_method']) && !empty($value['payment_method'])) {
287
  $keys[ $key ] = $value['payment_method'];
288
  }
289
+ if(isset($value['shipping_method'])) {
290
+ $pm_k_remove = array();
291
+ if(is_array($value['shipping_method']))
292
+ foreach($value['shipping_method'] as $k => $v) {
293
+ if($v === '0') {
294
+ $pm_k_remove[] = $k;
295
+ }
296
+ }
297
+ foreach($pm_k_remove as $k_remove) {
298
+ unset($value['shipping_method'][$k_remove]);
299
+ }
300
+ }
301
+ if(isset($value['shipping_method']) && !empty($value['shipping_method'])) {
302
+ $skeys[ $key ] = $value['shipping_method'];
303
+ }
304
  }
305
  }
306
  }
307
  ?>
308
  <script>
309
  var $keys = <?php if( isset($keys) ) echo json_encode($keys); else echo '[]'; ?>;
310
+ var $skeys = <?php if( isset($skeys) ) echo json_encode($skeys); else echo '[]'; ?>;
311
  function corect_payment_method_filds () {
312
  var selected_p_method = jQuery("input[name=\"payment_method\"]:checked").val();
313
  jQuery.each($keys, function(i,e){
319
  }
320
  });
321
  }
322
+ function corect_shipping_method_filds () {
323
+ var selected_s_method = jQuery("input.shipping_method:checked, input.shipping_method[type=\"hidden\"], select.shipping_method").val().split(":")[0];
324
+ jQuery.each($skeys, function(i,e){
325
+ if( jQuery.inArray( selected_s_method, e ) >= 0 ) {
326
+ jQuery("#" + i + "_field").show('slow');
327
+ } else {
328
+ jQuery("#" + i + "_field").hide('slow');
329
+ }
330
+ });
331
+ }
332
  jQuery("body").delegate("input[name=\"payment_method\"]", 'click', function(){
333
  corect_payment_method_filds ();
334
  });
335
+ jQuery("body").delegate("input.shipping_method", 'click', function(){
336
+ corect_shipping_method_filds ();
337
+ });
338
+ jQuery("body").delegate("select.shipping_method", 'change', function(){
339
+ corect_shipping_method_filds ();
340
+ });
341
  jQuery('body').bind('updated_checkout', function() {
342
  corect_payment_method_filds ();
343
+ corect_shipping_method_filds ();
344
  });
345
  </script>
346
  <?php
507
  }
508
  public function woocommerce_default_address_fields($locale) {
509
  $fieldss = get_option('woocommerce_saphali_filds_locate');
510
+ if(is_array($fieldss)) {
511
+ foreach($fieldss as $_k => $_v) {
512
+ $_fieldss[$_k] = $_v;
513
+ if(isset($_v['label'])) {
514
+ $_fieldss[$_k] = __( $_v['label'], 'woocommerce');
515
+ }
516
+ if(isset($_v['placeholder'])) {
517
+ $_fieldss[$_k] = __( $_v['placeholder'], 'woocommerce');
518
+ }
519
+ }
520
+ $locale = $_fieldss;
521
+ }
522
+
523
  return $locale;
524
  }
525
  public function woocommerce_get_country_locale($locale) {
741
  $filds = $global_f_checkout_fields;
742
 
743
  if(is_array($filds["billing"])) {
744
+ if(!isset($addFild["billing"]) || isset($addFild["billing"]) && !is_array($addFild["billing"])) $addFild["billing"] = array();
745
  if(!is_array($_POST["billing"])) $_POST["billing"] = array();
746
  $filds["billing"] = array_merge($filds["billing"] , $_POST["billing"], $addFild["billing"]);
747
 
748
  foreach($filds["billing"] as $key_post => $value_post) {
749
 
750
+ if( !isset($global_f_checkout_fields["billing"][$key_post]['type']) && (isset($filds["billing"][$key_post]['type']) && $filds["billing"][$key_post]['type'] != 'select' && $filds["billing"][$key_post]['type'] != 'checkbox' && $filds["billing"][$key_post]['type'] != 'textarea' || !isset($filds["billing"][$key_post]['type'])) ) unset($filds["billing"][$key_post]['type'], $value_post["type"]);
751
 
752
 
753
  if(@$filds["billing"][$key_post]['public'] != 'on') {
768
  }
769
 
770
  }
771
+ if(isset($filds["shipping"]) && is_array($filds["shipping"])) {
772
+ if(!isset($addFild["shipping"]) || isset($addFild["shipping"]) && !is_array($addFild["shipping"])) $addFild["shipping"] = array();
773
  if(!is_array($_POST["shipping"])) $_POST["shipping"] = array();
774
  $filds["shipping"] = array_merge($filds["shipping"] , $_POST["shipping"], $addFild["shipping"]);
775
  foreach($filds["shipping"] as $key_post => $value_post) {
791
  unset($_POST["shipping"][$key_post]);
792
  }
793
  }
794
+ if(isset($filds["order"]) && is_array($filds["order"])) {
795
+ if(!isset($addFild["order"]) || isset($addFild["order"]) && !is_array($addFild["order"])) $addFild["order"] = array();
796
  if(!is_array($_POST["order"])) $_POST["order"] = array();
797
  $filds["order"] = array_merge($filds["order"] , $_POST["order"], $addFild["order"]);
798
 
838
  unset($filds_finish_filter["billing"][$v_filt]);
839
  }
840
  }
841
+ if(isset($fild_remove_filter["shipping"]) && is_array($fild_remove_filter["shipping"])) {
842
  foreach($fild_remove_filter["shipping"] as $v_filt){
843
  unset($filds_finish_filter["shipping"][$v_filt]);
844
  }
845
  }
846
+ if(isset($fild_remove_filter["order"]) && is_array($fild_remove_filter["order"])) {
847
  foreach($fild_remove_filter["order"] as $v_filt){
848
  unset($filds_finish_filter["order"][$v_filt]);
849
  }
885
 
886
  <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
887
  <th width="120px">Метод оплаты</th>
888
+ <th width="120px">Метод доставки</th>
889
  <th width="65px">Удалить/До&shy;ба&shy;вить</th>
890
  </tr>
891
  </thead>
901
 
902
  <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
903
  <th width="120px">Метод оплаты</th>
904
+ <th width="120px">Метод доставки</th>
905
  <th>Удалить/До&shy;ба&shy;вить</th>
906
  </tr>
907
  </tfoot>
918
 
919
  $public = 'public';
920
  if( !version_compare( WOOCOMMERCE_VERSION, '3.0', '<' ) ) {
921
+ if( isset( $checkout_fields["billing"][$key][$public] ) ) $value[$public] = $checkout_fields["billing"][$key][$public];
922
+ elseif( isset( $checkout_fields["billing"][$key] ) ) {
923
+ $value[$public] = '';
924
+ }
925
  }
926
  if(isset($checkout_fields["billing"][$key]['payment_method'])) {
927
  $pm_k_remove = array();
936
  }
937
  if( isset( $checkout_fields["billing"][$key] ) ) $value['payment_method'] = $checkout_fields["billing"][$key]['payment_method'];
938
  }
939
+ if(isset($checkout_fields["billing"][$key]['shipping_method'])) {
940
+ $pm_k_remove = array();
941
+ foreach($checkout_fields["billing"][$key]['shipping_method'] as $k => $v) {
942
+ if($v === '0') {
943
+ $pm_k_remove[] = $k;
944
+ }
945
+ }
946
+
947
+ foreach($pm_k_remove as $k_remove) {
948
+ unset($checkout_fields["billing"][$key]['shipping_method'][$k_remove]);
949
+ }
950
+ if( isset( $checkout_fields["billing"][$key] ) ) $value['shipping_method'] = $checkout_fields["billing"][$key]['shipping_method'];
951
+ }
952
 
953
  if(empty($value[$public]) && !is_array($checkout_fields["billing"])) $value[$public] = true;
954
  ?>
990
  ?>
991
  </select>
992
  </td>
993
+ <td>
994
+ <select multiple="multiple" width="120px" name="billing[<?php echo $key?>][shipping_method][]">
995
+ <option value="0"<?php if( isset($value['shipping_method']) && ( in_array('0', $value['shipping_method']) || empty($value['shipping_method']) ) || !isset($value['shipping_method']) ) echo 'selected';?>>Все</option>
996
+ <?php
997
+ foreach ( $woocommerce->shipping->get_shipping_methods() as $act_id => $shipping ) {
998
+ if ( $shipping->enabled != 'yes' ) continue;
999
+ ?><option value="<?php echo $act_id; ?>" <?php if(isset($value['shipping_method']) && in_array($act_id, $value['shipping_method']) ) echo 'selected';?>><?php echo $shipping->title ? $shipping->title: $shipping->method_title; ?></option><?php
1000
+ }
1001
+ ?>
1002
+ </select>
1003
+ </td>
1004
  <td><input rel="sort_order" id="order_count" type="hidden" name="billing[<?php echo $key?>][order]" value="<?php echo $count?>" />
1005
  <input type="button" class="button" id="billing_delete" value="Удалить -"/></td>
1006
  </tr>
1036
 
1037
  <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
1038
  <th width="120px">Метод оплаты</th>
1039
+ <th width="120px">Метод доставки</th>
1040
  <th width="65px">Удалить/До&shy;ба&shy;вить</th>
1041
  </tr>
1042
  </thead>
1051
 
1052
  <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
1053
  <th width="120px">Метод оплаты</th>
1054
+ <th width="120px">Метод доставки</th>
1055
  <th>Удалить/До&shy;ба&shy;вить</th>
1056
  </tr>
1057
  </tfoot>
1077
  }
1078
  if( isset( $checkout_fields["shipping"][$key] ) ) $value['payment_method'] = $checkout_fields["shipping"][$key]['payment_method'];
1079
  }
1080
+ if(isset($checkout_fields["shipping"][$key]['shipping_method'])) {
1081
+ $pm_k_remove = array();
1082
+ foreach($checkout_fields["shipping"][$key]['shipping_method'] as $k => $v) {
1083
+ if($v === '0') {
1084
+ $pm_k_remove[] = $k;
1085
+ }
1086
+ }
1087
+
1088
+ foreach($pm_k_remove as $k_remove) {
1089
+ unset($checkout_fields["shipping"][$key]['shipping_method'][$k_remove]);
1090
+ }
1091
+ if( isset( $checkout_fields["shipping"][$key] ) ) $value['shipping_method'] = $checkout_fields["shipping"][$key]['shipping_method'];
1092
+ }
1093
  if( empty($value['public']) && !is_array($checkout_fields["shipping"]) ) $value['public'] = true;
1094
  ?>
1095
  <tr>
1096
  <td><input disabled value=<?php echo $key?> type="text" name="shipping[<?php echo $key?>][name]" /></td>
1097
+ <td><input value='<?php echo isset($value['label']) ? $value['label']: ''; ?>' type="text" name="shipping[<?php echo $key?>][label]" /><input value='<?php echo isset($value['type']) ? $value['type']: '' ?>' type="hidden" name="shipping[<?php echo $key?>][type]" /></td>
1098
  <td><input value='<?php if(isset( $value['placeholder'] )) echo $value['placeholder']; ?>' type="text" name="shipping[<?php echo $key?>][placeholder]" /></td>
1099
+ <td><input <?php if(isset($value['clear']) && $value['clear']) echo 'checked'?> class="<?php echo isset($value['clear'])? $value['clear'] : ''; ?>" type="checkbox" name="shipping[<?php echo $key?>][clear]" /></td>
1100
  <td><?php if( isset($value['class']) && is_array($value['class']) ) { foreach($value['class'] as $v_class) { ?>
1101
 
1102
  <input value='<?php echo $v_class;?>' type="text" name="shipping[<?php echo $key?>][class][]" /> <?php } } else { ?>
1114
  }
1115
  ?>
1116
  </select>
1117
+ </td><td>
1118
+ <select multiple="multiple" width="120px" name="shipping[<?php echo $key?>][shipping_method][]">
1119
+ <option value="0" <?php if( isset($value['shipping_method']) && ( in_array('0', $value['shipping_method']) || empty($value['shipping_method']) ) || !isset($value['shipping_method']) ) echo 'selected';?>>Все</option>
1120
+ <?php
1121
+ foreach ( $woocommerce->shipping->get_shipping_methods() as $act_id => $shipping ) {
1122
+ if ( $shipping->enabled != 'yes' ) continue;
1123
+ ?><option value="<?php echo $act_id; ?>" <?php if(isset($value['shipping_method']) && in_array($act_id, $value['shipping_method']) ) echo 'selected';?>><?php echo $shipping->title ? $shipping->title: $shipping->method_title; ?></option><?php
1124
+ }
1125
+ ?>
1126
+ </select>
1127
  </td>
1128
 
1129
  <td><input rel="sort_order" id="order_count" type="hidden" name="shipping[<?php echo $key?>][order]" value="<?php echo $count?>" /><input type="button" class="button" id="billing_delete" value="Удалить -"/>
1291
  }
1292
  ?>\
1293
  </select>\
1294
+ </td>' + '<td>\
1295
+ <select multiple="multiple" width="120px" name="billing[new_fild][shipping_method][]">\
1296
+ <option selected value="0">Все</option>\
1297
+ <?php
1298
+ foreach ( $woocommerce->shipping->get_shipping_methods() as $act_id => $shipping ) {
1299
+ if ( $shipping->enabled != 'yes' ) continue;
1300
+ ?><option value="<?php echo $act_id; ?>" <?php if(isset($value['shipping_method']) && in_array($act_id, $value['shipping_method']) ) echo 'selected';?>><?php $st = $shipping->title ? $shipping->title: $shipping->method_title; echo str_replace("'", "\\'", $st); ?></option><?php
1301
+ }
1302
+ ?>\
1303
+ </select>\
1304
  </td>';
1305
  obj.html('<td><input value="billing_new_fild'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" type="text" name="billing[new_fild][name][]" /></td><td><input value="" type="text" name="billing[new_fild][label][]" /></td><td><input value="" type="text" name="billing[new_fild][placeholder][]" /></td><td><input type="checkbox" name="billing[new_fild][clear][]" /></td><td><input value="" type="text" name="billing[new_fild][class][]" /></td><td> Select <input type="radio" value="select" name="billing[new_fild][type]"><br>Radio <input type="radio" value="radio" name="billing[new_fild][type]"><br>Checkbox <input type="radio" value="checkbox" name="billing[new_fild][type]"><br> Textarea <input type="radio" value="textarea" name="billing[new_fild][type]"><br> Text <input type="radio" value="" name="billing[new_fild][type]" checked="checked"></td><td><input checked type="checkbox" name="billing[new_fild][required][]" /></td><td><input checked type="checkbox" name="billing[new_fild][public][]" /></td>' + fild_pm + '<td><input id="order_count" rel="sort_order" type="hidden" name="billing[new_fild][order][]" value="'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" /><input type="button" class="button" id="billing_delete" value="Удалить -"/></td>');
1306
  obj.removeClass('nodrop nodrag');
1318
  }
1319
  ?>\
1320
  </select>\
1321
+ </td>' + '<td>\
1322
+ <select multiple="multiple" width="120px" name="shipping[new_fild][shipping_method][]">\
1323
+ <option selected value="0">Все</option>\
1324
+ <?php
1325
+ foreach ( $woocommerce->shipping->get_shipping_methods() as $act_id => $shipping ) {
1326
+ if ( $shipping->enabled != 'yes' ) continue;
1327
+ ?><option value="<?php echo $act_id; ?>" <?php if(isset($value['shipping_method']) && in_array($act_id, $value['shipping_method']) ) echo 'selected';?>><?php $st = $shipping->title ? $shipping->title: $shipping->method_title; echo str_replace("'", "\\'", $st); ?></option><?php
1328
+ }
1329
+ ?>\
1330
+ </select>\
1331
  </td>';
1332
  obj.html('<td><input value="shipping_new_fild'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" type="text" name="shipping[new_fild][name][]" /></td><td><input value="" type="text" name="shipping[new_fild][label][]" /></td><td><input value="" type="text" name="shipping[new_fild][placeholder][]" /></td><td><input type="checkbox" name="shipping[new_fild][clear][]" /></td><td><input value="" type="text" name="shipping[new_fild][class][]" /></td><td><input checked type="checkbox" name="shipping[new_fild][required][]" /></td><td><input checked type="checkbox" name="shipping[new_fild][public][]" /></td>' + fild_pm + '<td><input id="order_count" rel="sort_order" type="hidden" name="shipping[new_fild][order][]" value="'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" /><input type="button" class="button" id="billing_delete" value="Удалить -"/></td>');
1333
  obj.removeClass('nodrop nodrag');
1397
  'description' => ''
1398
  ),
1399
  'billing_city' => array(
1400
+ 'label' => __('Town / City', 'woocommerce'),
1401
  'description' => ''
1402
  ),
1403
  'billing_postcode' => array(
1404
+ 'label' => __('Postcode / ZIP', 'woocommerce'),
1405
  'description' => ''
1406
  ),
1407
  'billing_state' => array(
1408
+ 'label' => __('State / County', 'woocommerce'),
1409
  'description' => __('Country or state code', 'woocommerce'),
1410
  ),
1411
  'billing_country' => array(
1634
  if(isset($fields[$v][$key]["label"]))
1635
  $fields[$v][$key]["label"] = __($value["label"], 'woocommerce');
1636
  if(isset($fields[$v][$key]["placeholder"]))
1637
+ $fields[$v][$key]["placeholder"] = __( __($value["placeholder"], 'saphali-woocommerce-lite'), 'woocommerce');
1638
  }
1639
  return $fields;
1640
  }