Saphali Woocommerce Russian - Version 1.2.3.1

Version Description

  • repository
Download this release

Release Info

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

Code changes from version 1.2.2 to 1.2.3.1

Files changed (2) hide show
  1. readme.txt +18 -2
  2. saphali-woocommerce-lite.php +313 -31
readme.txt CHANGED
@@ -6,8 +6,8 @@ Donate link: http://saphali.com/
6
  Tags: woocommerce, woo commerce russian, russian ruble, ukrainian hryvnia, mod, manadger filds checkout
7
  Requires at least: 3.3 or higher
8
  Tested up to: 3.4.2
9
- Stable tag: 1.2.2
10
- Version: 1.2.2
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -43,6 +43,13 @@ Saphali - set of additions to Woocommerce.
43
 
44
  == Changelog ==
45
 
 
 
 
 
 
 
 
46
  = 1.2.2 =
47
  * На странице управления дополнительными полями и полями доставки в заголовке к атрибутам "Название" и "Класс поля" добавлена подсказка.
48
  * Задан стиль для неактивного поля.
@@ -78,6 +85,15 @@ Saphali - set of additions to Woocommerce.
78
 
79
  == Upgrade Notice ==
80
 
 
 
 
 
 
 
 
 
 
81
  = 1.2.1 =
82
  * На странице управления дополнительными полями и полями доставки в заголовке к атрибуту clear добавлена подсказка.
83
 
6
  Tags: woocommerce, woo commerce russian, russian ruble, ukrainian hryvnia, mod, manadger filds checkout
7
  Requires at least: 3.3 or higher
8
  Tested up to: 3.4.2
9
+ Stable tag: 1.2.3.1
10
+ Version: 1.2.3.1
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
43
 
44
  == Changelog ==
45
 
46
+ = 1.2.3.1 =
47
+ * Ошибка загрузки в repository
48
+
49
+ = 1.2.3 =
50
+ * На странице управления дополнительными полями и полями доставки исправлена ошибка добавления полей.
51
+ * Добавлен вывод дополнительных полей на странице профиля пользователя, а также на странице редактирования заказа.
52
+
53
  = 1.2.2 =
54
  * На странице управления дополнительными полями и полями доставки в заголовке к атрибутам "Название" и "Класс поля" добавлена подсказка.
55
  * Задан стиль для неактивного поля.
85
 
86
  == Upgrade Notice ==
87
 
88
+ = 1.2.3 =
89
+ * На странице управления дополнительными полями и полями доставки исправлена ошибка добавления полей.
90
+ * Добавлен вывод дополнительных полей на странице профиля пользователя, а также на странице редактирования заказа.
91
+
92
+ = 1.2.2 =
93
+ * На странице управления дополнительными полями и полями доставки в заголовке к атрибутам "Название" и "Класс поля" добавлена подсказка.
94
+ * Задан стиль для неактивного поля.
95
+ * Небольшие исправления.
96
+
97
  = 1.2.1 =
98
  * На странице управления дополнительными полями и полями доставки в заголовке к атрибуту clear добавлена подсказка.
99
 
saphali-woocommerce-lite.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Saphali Woocommerce LITE
4
  Plugin URI: http://saphali.com/saphali-woocommerce-plugin-wordpress
5
  Description: Saphali Woocommerce LITE - это бесплатный вордпресс плагин, который добавляет набор дополнений к интернет-магазину на Woocommerce.
6
- Version: 1.2.2
7
  Author: Saphali
8
  Author URI: http://saphali.com/
9
  */
@@ -31,39 +31,315 @@ Author URI: http://saphali.com/
31
  // Подключение валюты и локализации
32
  define('SAPHALI_PLUGIN_DIR_URL',plugin_dir_url(__FILE__));
33
  define('SAPHALI_PLUGIN_DIR_PATH',plugin_dir_path(__FILE__));
34
- function add_inr_currency( $currencies ) {
35
- $currencies['UAH'] = __( 'Ukrainian hryvnia ( grn.)', 'themewoocommerce' );
36
- $currencies['RUR'] = __( 'Russian ruble ( rub.)', 'themewoocommerce' );
37
- $currencies['BYR'] = __( 'Belarusian ruble ( Br.)', 'themewoocommerce' );
38
- return $currencies;
 
 
39
  }
40
-
41
- function add_inr_currency_symbol( $symbol ) {
42
- $currency = get_option( 'woocommerce_currency' );
43
- switch( $currency ) {
44
- case 'UAH': $symbol = 'грн.'; break;
45
- case 'RUB': $symbol = 'руб.'; break;
46
- case 'RUR': $symbol = 'руб.'; break;
47
- case 'BYR': $symbol = 'руб.'; break;
 
 
48
  }
49
- return $symbol;
50
  }
51
 
52
-
53
  //END
54
 
55
- add_action('plugins_loaded', 'woocommerce_lang', 0);
56
- function woocommerce_lang() {
 
57
 
58
- add_action('admin_menu', 'woocommerce_saphali_admin_menu', 9);
59
  load_plugin_textdomain( 'woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
60
  load_plugin_textdomain( 'themewoocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
61
- if($_GET['page'] != 'woocommerce_saphali' && $_GET['tab'] !=1) {
 
62
  // Hook in
63
  add_filter( 'woocommerce_checkout_fields' , 'saphali_custom_override_checkout_fields' );
64
  add_filter( 'woocommerce_billing_fields', 'saphali_custom_billing_fields', 10, 1 );
65
  add_filter( 'woocommerce_shipping_fields', 'saphali_custom_shipping_fields', 10, 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  // Our hooked in function - $fields is passed via the filter!
68
  function saphali_custom_override_checkout_fields( $fields ) {
69
 
@@ -94,12 +370,12 @@ function woocommerce_lang() {
94
  add_action( 'admin_enqueue_scripts', 'admin_enqueue_scripts_page_saphali' );
95
 
96
  function admin_enqueue_scripts_page_saphali() {
97
- if($_GET['page'] == 'woocommerce_saphali' && $_GET['tab'] ==1 )
98
  wp_enqueue_script( 'tablednd', plugins_url('/js/jquery.tablednd.0.5.js', __FILE__) );
99
  }
100
 
101
 
102
- function woocommerce_saphali_page () {
103
 
104
 
105
  ?>
@@ -109,9 +385,9 @@ function woocommerce_lang() {
109
  </h2>
110
  <ul class="subsubsub">
111
 
112
- <li><a href="admin.php?page=woocommerce_saphali" <? if($_GET["tab"] == '') echo 'class="current"';?>><span color="red">Дополнительная информация</span></a> | </li>
113
- <li><a href="admin.php?page=woocommerce_saphali&tab=1" <? if($_GET["tab"] == 1) echo 'class="current"';?>>Управление полями</a> | </li>
114
- <li><a href="admin.php?page=woocommerce_saphali&tab=2" <? if($_GET["tab"] == 2) echo 'class="current"';?>>Число колонок в каталоге</a></li>
115
 
116
  </ul>
117
  <? if($_GET["tab"] == '') {?>
@@ -130,6 +406,7 @@ function woocommerce_lang() {
130
  if($_POST){
131
  if($_POST["reset"] != 'All') {
132
  // Управление новыми полями
 
133
  if(is_array($_POST["billing"]["new_fild"])) {
134
  foreach($_POST["billing"]["new_fild"] as $k_nf => $v_nf) {
135
  if($k_nf == 'name')
@@ -146,6 +423,7 @@ function woocommerce_lang() {
146
  }
147
  }
148
  unset($_POST["billing"]["new_fild"]);
 
149
  }
150
  if(is_array($_POST["shipping"]["new_fild"])) {
151
  foreach($_POST["shipping"]["new_fild"] as $k_nf => $v_nf) {
@@ -163,6 +441,7 @@ function woocommerce_lang() {
163
  }
164
  }
165
  unset($_POST["shipping"]["new_fild"]);
 
166
  }
167
  if(is_array($_POST["order"]["new_fild"])) {
168
  foreach($_POST["order"]["new_fild"] as $k_nf => $v_nf) {
@@ -434,7 +713,7 @@ function woocommerce_lang() {
434
  </tr>
435
  </tfoot>
436
  <tbody id="the-list" class="myTable">
437
- <? $count = 0;
438
  if(is_array($checkout_fields["shipping"])) $f->checkout_fields["shipping"] = $checkout_fields["shipping"];
439
  foreach($f->checkout_fields["shipping"] as $key => $value) {
440
  if( empty($value['public']) && !is_array($checkout_fields["shipping"]) ) $value['public'] = true;
@@ -559,19 +838,19 @@ function woocommerce_lang() {
559
  });
560
  jQuery('.button#billing').live('click',function() {
561
  var obj = jQuery(this).parent().parent();
562
- obj.html('<td><input value="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><input checked type="checkbox" name="billing[new_fild][required][]" /></td><td><input checked type="checkbox" name="billing[new_fild][public][]" /></td><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>');
563
  obj.removeClass('nodrop nodrag');
564
  obj.after('<tr class="nodrop nodrag"><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><input type="button" class="button" id="billing" value="Добавить +"/></td></tr>');
565
  });
566
  jQuery('.button#shipping').live('click',function() {
567
  var obj = jQuery(this).parent().parent();
568
- obj.html('<td><input value="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><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>');
569
  obj.removeClass('nodrop nodrag');
570
  obj.after('<tr class="nodrop nodrag"><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><input type="button" class="button" id="shipping" value="Добавить +"/></td></tr>');
571
  });
572
  jQuery('.button#order').live('click',function() {
573
  var obj = jQuery(this).parent().parent();
574
- obj.html('<td><input value="new_fild'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" type="text" name="order[new_fild][name][]" /></td><td><input value="" type="text" name="order[new_fild][label][]" /></td><td><input value="" type="text" name="order[new_fild][placeholder][]" /></td><td><input value="" type="text" name="order[new_fild][class][]" /></td><td><input checked type="text" name="order[new_fild][type][]" /></td><td><input checked type="checkbox" name="order[new_fild][public][]" /></td><td><input id="order_count" rel="sort_order" type="hidden" name="order[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>');
575
  obj.removeClass('nodrop nodrag');
576
  obj.after('<tr class="nodrop nodrag"><td></td><td></td><td></td><td></td><td></td><td></td><td><input type="button" class="button" id="order" value="Добавить +"/></td></tr>');
577
  });
@@ -608,8 +887,11 @@ function woocommerce_lang() {
608
  <?
609
  }
610
  }
611
- function woocommerce_saphali_admin_menu() {
612
- add_submenu_page('woocommerce', __('Настройки Saphali WC Lite', 'woocommerce'), __('Saphali WC Lite', 'woocommerce') , 'manage_woocommerce', 'woocommerce_saphali', 'woocommerce_saphali_page');
 
 
 
613
  }
614
  $column_count_saphali = get_option('column_count_saphali');
615
  if(!empty($column_count_saphali)) {
3
  Plugin Name: Saphali Woocommerce LITE
4
  Plugin URI: http://saphali.com/saphali-woocommerce-plugin-wordpress
5
  Description: Saphali Woocommerce LITE - это бесплатный вордпресс плагин, который добавляет набор дополнений к интернет-магазину на Woocommerce.
6
+ Version: 1.2.3.1
7
  Author: Saphali
8
  Author URI: http://saphali.com/
9
  */
31
  // Подключение валюты и локализации
32
  define('SAPHALI_PLUGIN_DIR_URL',plugin_dir_url(__FILE__));
33
  define('SAPHALI_PLUGIN_DIR_PATH',plugin_dir_path(__FILE__));
34
+ if ( ! function_exists( 'add_inr_currency' ) ) {
35
+ function add_inr_currency( $currencies ) {
36
+ $currencies['UAH'] = __( 'Ukrainian hryvnia ( grn.)', 'themewoocommerce' );
37
+ $currencies['RUR'] = __( 'Russian ruble ( rub.)', 'themewoocommerce' );
38
+ $currencies['BYR'] = __( 'Belarusian ruble ( Br.)', 'themewoocommerce' );
39
+ return $currencies;
40
+ }
41
  }
42
+ if ( ! function_exists( 'add_inr_currency_symbol' ) ) {
43
+ function add_inr_currency_symbol( $symbol ) {
44
+ $currency = get_option( 'woocommerce_currency' );
45
+ switch( $currency ) {
46
+ case 'UAH': $symbol = 'грн.'; break;
47
+ case 'RUB': $symbol = 'руб.'; break;
48
+ case 'RUR': $symbol = 'руб.'; break;
49
+ case 'BYR': $symbol = 'руб.'; break;
50
+ }
51
+ return $symbol;
52
  }
 
53
  }
54
 
 
55
  //END
56
 
57
+ add_action('plugins_loaded', 'woocommerce_lang_s_l', 0);
58
+ if ( ! function_exists( 'woocommerce_lang_s_l' ) ) {
59
+ function woocommerce_lang_s_l() {
60
 
61
+ add_action('admin_menu', 'woocommerce_saphali_admin_menu_s_l', 9);
62
  load_plugin_textdomain( 'woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
63
  load_plugin_textdomain( 'themewoocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
64
+
65
+ if($_GET['page'] != 'woocommerce_saphali_s_l' && $_GET['tab'] !=1) {
66
  // Hook in
67
  add_filter( 'woocommerce_checkout_fields' , 'saphali_custom_override_checkout_fields' );
68
  add_filter( 'woocommerce_billing_fields', 'saphali_custom_billing_fields', 10, 1 );
69
  add_filter( 'woocommerce_shipping_fields', 'saphali_custom_shipping_fields', 10, 1 );
70
+ add_action('admin_init','woocommerce_customer_meta_fields_action', 20);
71
+ add_action( 'personal_options_update', 'woocommerce_save_customer_meta_fields_saphali' );
72
+ add_action( 'edit_user_profile_update', 'woocommerce_save_customer_meta_fields_saphali' );
73
+ add_action( 'woocommerce_admin_order_data_after_billing_address', 'woocommerce_admin_order_data_after_billing_address_s' );
74
+ add_action( 'woocommerce_admin_order_data_after_shipping_address', 'woocommerce_admin_order_data_after_shipping_address_s' );
75
+ add_action( 'woocommerce_admin_order_data_after_order_details', 'woocommerce_admin_order_data_after_order_details_s' );
76
+
77
+ }
78
+
79
+ /*Начало*/
80
+ function woocommerce_customer_meta_fields_action() {
81
+ add_action( 'show_user_profile', 'woocommerce_customer_meta_fields_s');
82
+ add_action( 'edit_user_profile', 'woocommerce_customer_meta_fields_s' );
83
+ }
84
+ function woocommerce_customer_meta_fields_s( $user ) {
85
+ if ( ! current_user_can( 'manage_woocommerce' ) )
86
+ return;
87
+
88
+ $show_fields = woocommerce_get_customer_meta_fields_saphali();
89
+ if(!empty($show_fields["billing"])) {
90
+ $show_field["billing"]['title'] = __('Customer Billing Address', 'woocommerce');
91
+ $show_field["billing"]['fields'] = $show_fields["billing"];
92
+ }
93
+ if(!empty($show_fields["shipping"])) {
94
+ $show_field["shipping"]['title'] = __('Customer Shipping Address', 'woocommerce');
95
+ $show_field["shipping"]['fields'] = $show_fields["shipping"];
96
+ }
97
+ if(is_array($show_field)) {
98
+ $count = 0; echo '<fieldset>';
99
+ foreach( $show_field as $fieldset ) :
100
+ if(!$count) echo '<h2>Дополнительные поля</h2>';
101
+ $count++;
102
+ ?>
103
+ <h3><?php echo $fieldset['title']; ?></h3>
104
+ <table class="form-table">
105
+ <?php
106
+ foreach( $fieldset['fields'] as $key => $field ) :
107
+ ?>
108
+ <tr>
109
+ <th><label for="<?php echo $key; ?>"><?php echo $field['label']; ?></label></th>
110
+ <td>
111
+ <input type="text" name="<?php echo $key; ?>" id="<?php echo $key; ?>" value="<?php echo esc_attr( get_user_meta( $user->ID, $key, true ) ); ?>" class="regular-text" /><br/>
112
+ <span class="description"><?php echo $field['description']; ?></span>
113
+ </td>
114
+ </tr>
115
+ <?php
116
+ endforeach;
117
+ ?>
118
+ </table>
119
+ <?php
120
+ endforeach; echo '</fieldset>';
121
+ }
122
+ }
123
+
124
+ function woocommerce_get_customer_meta_fields_saph_ed() {
125
+ $show_fields = apply_filters('woocommerce_customer_meta_fields', array(
126
+ 'billing' => array(
127
+ 'title' => __('Customer Billing Address', 'woocommerce'),
128
+ 'fields' => array(
129
+ 'billing_first_name' => array(
130
+ 'label' => __('First name', 'woocommerce'),
131
+ 'description' => ''
132
+ ),
133
+ 'billing_last_name' => array(
134
+ 'label' => __('Last name', 'woocommerce'),
135
+ 'description' => ''
136
+ ),
137
+ 'billing_company' => array(
138
+ 'label' => __('Company', 'woocommerce'),
139
+ 'description' => ''
140
+ ),
141
+ 'billing_address_1' => array(
142
+ 'label' => __('Address 1', 'woocommerce'),
143
+ 'description' => ''
144
+ ),
145
+ 'billing_address_2' => array(
146
+ 'label' => __('Address 2', 'woocommerce'),
147
+ 'description' => ''
148
+ ),
149
+ 'billing_city' => array(
150
+ 'label' => __('City', 'woocommerce'),
151
+ 'description' => ''
152
+ ),
153
+ 'billing_postcode' => array(
154
+ 'label' => __('Postcode', 'woocommerce'),
155
+ 'description' => ''
156
+ ),
157
+ 'billing_state' => array(
158
+ 'label' => __('State/County', 'woocommerce'),
159
+ 'description' => __('Country or state code', 'woocommerce'),
160
+ ),
161
+ 'billing_country' => array(
162
+ 'label' => __('Country', 'woocommerce'),
163
+ 'description' => __('2 letter Country code', 'woocommerce'),
164
+ ),
165
+ 'billing_phone' => array(
166
+ 'label' => __('Telephone', 'woocommerce'),
167
+ 'description' => ''
168
+ ),
169
+ 'billing_email' => array(
170
+ 'label' => __('Email', 'woocommerce'),
171
+ 'description' => ''
172
+ )
173
+ )
174
+ ),
175
+ 'shipping' => array(
176
+ 'title' => __('Customer Shipping Address', 'woocommerce'),
177
+ 'fields' => array(
178
+ 'shipping_first_name' => array(
179
+ 'label' => __('First name', 'woocommerce'),
180
+ 'description' => ''
181
+ ),
182
+ 'shipping_last_name' => array(
183
+ 'label' => __('Last name', 'woocommerce'),
184
+ 'description' => ''
185
+ ),
186
+ 'shipping_company' => array(
187
+ 'label' => __('Company', 'woocommerce'),
188
+ 'description' => ''
189
+ ),
190
+ 'shipping_address_1' => array(
191
+ 'label' => __('Address 1', 'woocommerce'),
192
+ 'description' => ''
193
+ ),
194
+ 'shipping_address_2' => array(
195
+ 'label' => __('Address 2', 'woocommerce'),
196
+ 'description' => ''
197
+ ),
198
+ 'shipping_city' => array(
199
+ 'label' => __('City', 'woocommerce'),
200
+ 'description' => ''
201
+ ),
202
+ 'shipping_postcode' => array(
203
+ 'label' => __('Postcode', 'woocommerce'),
204
+ 'description' => ''
205
+ ),
206
+ 'shipping_state' => array(
207
+ 'label' => __('State/County', 'woocommerce'),
208
+ 'description' => __('State/County or state code', 'woocommerce')
209
+ ),
210
+ 'shipping_country' => array(
211
+ 'label' => __('Country', 'woocommerce'),
212
+ 'description' => __('2 letter Country code', 'woocommerce')
213
+ )
214
+ )
215
+ )
216
+ ));
217
+ return $show_fields;
218
+ }
219
+ function woocommerce_save_customer_meta_fields_saphali( $user_id ) {
220
+ if ( ! current_user_can( 'manage_woocommerce' ) )
221
+ return $columns;
222
+
223
+ $show_fields = woocommerce_get_customer_meta_fields_saphali();
224
+ if(!empty($show_fields["billing"])) {
225
+ $save_fields["billing"]['title'] = __('Customer Billing Address', 'woocommerce');
226
+ $save_fields["billing"]['fields'] = $show_fields["billing"];
227
+ }
228
+ if(!empty($show_fields["shipping"])) {
229
+ $save_fields["shipping"]['title'] = __('Customer Shipping Address', 'woocommerce');
230
+ $save_fields["shipping"]['fields'] = $show_fields["shipping"];
231
+ }
232
+ /* if(!empty($show_fields["order"])) {
233
+ $save_fields["order"]['title'] = __('Дополнительные поля', 'woocommerce');
234
+ $save_fields["order"]['fields'] = $show_fields["order"];
235
+ } */
236
+ foreach( $save_fields as $fieldset )
237
+ foreach( $fieldset['fields'] as $key => $field )
238
+ if ( isset( $_POST[ $key ] ) )
239
+ update_user_meta( $user_id, $key, trim( esc_attr( $_POST[ $key ] ) ) );
240
+ }
241
+ function woocommerce_get_customer_meta_fields_saphali() {
242
+ $fieldss = get_option('woocommerce_saphali_filds_filters');
243
+ $show_fields = woocommerce_get_customer_meta_fields_saph_ed();
244
+ if(is_array($fieldss)) {
245
+ if(is_array($fieldss["billing"])) {
246
+ $billing['fields'] = array();
247
+ foreach($fieldss["billing"] as $key => $value) {
248
+ if(isset($show_fields["billing"]['fields'][$key])) continue;
249
+ $billing['fields'] = $billing['fields'] +
250
+ array( $key => array(
251
+ 'label' => $value["label"],
252
+ 'show' => $value["public"],
253
+ 'description' => ''
254
+ )
255
+ );
256
+ }
257
+ }
258
+ if(is_array($fieldss["shipping"])) {
259
+ $shipping['fields'] = array();
260
+ foreach($fieldss["shipping"] as $key => $value) {
261
+ if(isset($show_fields["shipping"]['fields'][$key])) continue;
262
+ $shipping['fields'] = $shipping['fields'] +
263
+ array( $key => array(
264
+ 'label' => $value["label"],
265
+ 'show' => $value["public"],
266
+ 'description' => ''
267
+ )
268
+ );
269
+ }
270
+ }
271
+ if(is_array($fieldss["order"])) {
272
+ $orders['fields'] = array();
273
+ foreach($fieldss["order"] as $key => $value) {
274
+ if(isset($show_fields["order"]['fields'][$key])) continue;
275
+ $orders['fields'] = $orders['fields'] +
276
+ array( $key => array(
277
+ 'label' => $value["label"],
278
+ 'show' => $value["public"],
279
+ 'description' => ''
280
+ )
281
+ );
282
+ }
283
+ }
284
+ }
285
+ if(!is_array($show_fields['billing']['fields'])) { $show_fields['billing']['fields'] = array(); }
286
+ $show_fields['billing']['title'] = $show_fields['billing']['title'];
287
+ $show_fields['billing'] = /* $show_fields['billing']['fields'] + */ $billing['fields'];
288
+
289
+ if(!is_array($show_fields['shipping']['fields'])) { $show_fields['shipping']['fields'] = array(); }
290
+ $show_fields['shipping']['title'] = $show_fields['shipping']['title'];
291
+ $show_fields['shipping'] = /* $show_fields['shipping']['fields'] + */ $shipping['fields'];
292
+
293
+ if(!is_array($show_fields['order']['fields'])) { $show_fields['order']['fields'] = array(); $show_fields['order']['title'] = 'Дополнительные поля'; }
294
+ $show_fields['order'] = /* $show_fields['order']['fields'] + */ $orders['fields'];
295
+
296
+ return $show_fields;
297
  }
298
+ function woocommerce_admin_order_data_after_billing_address_s($order) {
299
+ $billing_data = woocommerce_get_customer_meta_fields_saphali();
300
+ echo '<div class="address">';
301
+ if(is_array($billing_data["billing"])) {
302
+ foreach ( $billing_data["billing"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
303
+
304
+ $field_name = '_'.$key;
305
+
306
+ if ( $order->order_custom_fields[$field_name][0] ) echo '<p><strong>'.$field['label'].':</strong> '.$order->order_custom_fields[$field_name][0].'</p>';
307
+
308
+ endforeach;
309
+ }
310
+ echo '</div>';
311
+ }
312
+ function woocommerce_admin_order_data_after_shipping_address_s($order) {
313
+ $billing_data = woocommerce_get_customer_meta_fields_saphali();
314
+ echo '<div class="address">';
315
+ if(is_array($billing_data["shipping"])) {
316
+ foreach ( $billing_data["shipping"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
317
+
318
+ $field_name = '_'.$key;
319
+
320
+ if ( $order->order_custom_fields[$field_name][0] ) echo '<p><strong>'.$field['label'].':</strong> '.$order->order_custom_fields[$field_name][0].'</p>';
321
+
322
+ endforeach;
323
+ }
324
+ echo '</div>';
325
+ }
326
+ function woocommerce_admin_order_data_after_order_details_s($order) {
327
+ $billing_data = woocommerce_get_customer_meta_fields_saphali();
328
+ echo '<div class="address">';
329
+ if(is_array($billing_data["order"])) {
330
+ foreach ( $billing_data["order"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
331
+
332
+ $field_name = '_'.$key;
333
+
334
+ if ( $order->order_custom_fields[$field_name][0] )
335
+
336
+ echo '<div class="form-field form-field-wide"><label>'. $field['label']. ':</label>' . $order->order_custom_fields[$field_name][0].'</div>';
337
+
338
+ endforeach;
339
+ }
340
+ echo '</div>';
341
+ }
342
+ /*Конец*/
343
  // Our hooked in function - $fields is passed via the filter!
344
  function saphali_custom_override_checkout_fields( $fields ) {
345
 
370
  add_action( 'admin_enqueue_scripts', 'admin_enqueue_scripts_page_saphali' );
371
 
372
  function admin_enqueue_scripts_page_saphali() {
373
+ if($_GET['page'] == 'woocommerce_saphali_s_l' && $_GET['tab'] ==1 )
374
  wp_enqueue_script( 'tablednd', plugins_url('/js/jquery.tablednd.0.5.js', __FILE__) );
375
  }
376
 
377
 
378
+ function woocommerce_saphali_page_s_l () {
379
 
380
 
381
  ?>
385
  </h2>
386
  <ul class="subsubsub">
387
 
388
+ <li><a href="admin.php?page=woocommerce_saphali_s_l" <? if($_GET["tab"] == '') echo 'class="current"';?>><span color="red">Дополнительная информация</span></a> | </li>
389
+ <li><a href="admin.php?page=woocommerce_saphali_s_l&tab=1" <? if($_GET["tab"] == 1) echo 'class="current"';?>>Управление полями</a> | </li>
390
+ <li><a href="admin.php?page=woocommerce_saphali_s_l&tab=2" <? if($_GET["tab"] == 2) echo 'class="current"';?>>Число колонок в каталоге</a></li>
391
 
392
  </ul>
393
  <? if($_GET["tab"] == '') {?>
406
  if($_POST){
407
  if($_POST["reset"] != 'All') {
408
  // Управление новыми полями
409
+
410
  if(is_array($_POST["billing"]["new_fild"])) {
411
  foreach($_POST["billing"]["new_fild"] as $k_nf => $v_nf) {
412
  if($k_nf == 'name')
423
  }
424
  }
425
  unset($_POST["billing"]["new_fild"]);
426
+ unset($new_fild);
427
  }
428
  if(is_array($_POST["shipping"]["new_fild"])) {
429
  foreach($_POST["shipping"]["new_fild"] as $k_nf => $v_nf) {
441
  }
442
  }
443
  unset($_POST["shipping"]["new_fild"]);
444
+ unset($new_fild);
445
  }
446
  if(is_array($_POST["order"]["new_fild"])) {
447
  foreach($_POST["order"]["new_fild"] as $k_nf => $v_nf) {
713
  </tr>
714
  </tfoot>
715
  <tbody id="the-list" class="myTable">
716
+ <? $count = 0;
717
  if(is_array($checkout_fields["shipping"])) $f->checkout_fields["shipping"] = $checkout_fields["shipping"];
718
  foreach($f->checkout_fields["shipping"] as $key => $value) {
719
  if( empty($value['public']) && !is_array($checkout_fields["shipping"]) ) $value['public'] = true;
838
  });
839
  jQuery('.button#billing').live('click',function() {
840
  var obj = jQuery(this).parent().parent();
841
+ 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><input checked type="checkbox" name="billing[new_fild][required][]" /></td><td><input checked type="checkbox" name="billing[new_fild][public][]" /></td><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>');
842
  obj.removeClass('nodrop nodrag');
843
  obj.after('<tr class="nodrop nodrag"><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><input type="button" class="button" id="billing" value="Добавить +"/></td></tr>');
844
  });
845
  jQuery('.button#shipping').live('click',function() {
846
  var obj = jQuery(this).parent().parent();
847
+ 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><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>');
848
  obj.removeClass('nodrop nodrag');
849
  obj.after('<tr class="nodrop nodrag"><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><input type="button" class="button" id="shipping" value="Добавить +"/></td></tr>');
850
  });
851
  jQuery('.button#order').live('click',function() {
852
  var obj = jQuery(this).parent().parent();
853
+ obj.html('<td><input value="order_new_fild'+(parseInt(obj.parent().find('tr td input#order_count:last').val(),10)+1)+'" type="text" name="order[new_fild][name][]" /></td><td><input value="" type="text" name="order[new_fild][label][]" /></td><td><input value="" type="text" name="order[new_fild][placeholder][]" /></td><td><input value="" type="text" name="order[new_fild][class][]" /></td><td><input checked type="text" name="order[new_fild][type][]" /></td><td><input checked type="checkbox" name="order[new_fild][public][]" /></td><td><input id="order_count" rel="sort_order" type="hidden" name="order[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>');
854
  obj.removeClass('nodrop nodrag');
855
  obj.after('<tr class="nodrop nodrag"><td></td><td></td><td></td><td></td><td></td><td></td><td><input type="button" class="button" id="order" value="Добавить +"/></td></tr>');
856
  });
887
  <?
888
  }
889
  }
890
+ }
891
+ if ( ! function_exists( 'woocommerce_saphali_admin_menu_s_l' ) ) {
892
+ function woocommerce_saphali_admin_menu_s_l() {
893
+ add_submenu_page('woocommerce', __('Настройки Saphali WC Lite', 'woocommerce'), __('Saphali WC Lite', 'woocommerce') , 'manage_woocommerce', 'woocommerce_saphali_s_l', 'woocommerce_saphali_page_s_l');
894
+ }
895
  }
896
  $column_count_saphali = get_option('column_count_saphali');
897
  if(!empty($column_count_saphali)) {