Saphali Woocommerce Russian - Version 1.6.6

Version Description

  • WC 3.x.x.
Download this release

Release Info

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

Code changes from version 1.6.5 to 1.6.6

Files changed (2) hide show
  1. readme.txt +4 -1
  2. saphali-woocommerce-lite.php +1501 -1488
readme.txt CHANGED
@@ -6,7 +6,7 @@ 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.7
9
- Stable tag: 1.6.5
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -72,6 +72,9 @@ define('SAPHALI_LITE_SYMBOL', 0 );
72
 
73
  == Changelog ==
74
 
 
 
 
75
  = 1.6.5 =
76
  * Fix вывода полей в профиле (исправлен вывод дублей).
77
 
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.7
9
+ Stable tag: 1.6.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
72
 
73
  == Changelog ==
74
 
75
+ = 1.6.6 =
76
+ * Исправлен учет публикации в настройках плагина в версии WC 3.x.x.
77
+
78
  = 1.6.5 =
79
  * Fix вывода полей в профиле (исправлен вывод дублей).
80
 
saphali-woocommerce-lite.php CHANGED
@@ -1,1489 +1,1502 @@
1
- <?php
2
- /*
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.6.5
7
- Author: Saphali
8
- Author URI: http://saphali.com/
9
- Text Domain: saphali-woocommerce-lite
10
- Domain Path: /languages
11
-
12
- */
13
-
14
-
15
- /*
16
-
17
- This program is free software; you can redistribute it and/or modify
18
- it under the terms of the GNU General Public License, version 2, as
19
- published by the Free Software Foundation.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program; if not, write to the Free Software
28
-
29
- */
30
-
31
- /* Add a custom payment class to woocommerce
32
- ------------------------------------------------------------ */
33
- define('SAPHALI_LITE_SYMBOL', 1 );
34
-
35
- // Подключение валюты и локализации
36
- define('SAPHALI_PLUGIN_DIR_URL',plugin_dir_url(__FILE__));
37
- define('SAPHALI_LITE_VERSION', '1.6.4' );
38
- define('SAPHALI_PLUGIN_DIR_PATH',plugin_dir_path(__FILE__));
39
- class saphali_lite {
40
- var $email_order_id;
41
- var $column_count_saphali;
42
- function __construct() {
43
- if ( version_compare( WOOCOMMERCE_VERSION, '2.2.0', '<' ) || version_compare( WOOCOMMERCE_VERSION, '2.5.0', '>' ) )
44
- add_action('before_woocommerce_init', array($this,'load_plugin_textdomain'), 9);
45
- else
46
- add_action('before_woocommerce_init', array($this,'load_plugin_textdomain_th'), 9);
47
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) ) add_action('admin_menu', array($this,'woocommerce_saphali_admin_menu_s_l'), 9);
48
- else add_action('admin_menu', array($this,'woocommerce_saphali_admin_menu_s_l'), 10);
49
-
50
- add_action( 'woocommerce_thankyou', array( $this, 'order_pickup_location' ), 20 );
51
- add_action( 'woocommerce_view_order', array( $this, 'order_pickup_location' ), 20 );
52
-
53
- add_action( 'woocommerce_after_template_part', array( $this, 'email_pickup_location' ), 10, 3 );
54
-
55
- // add_action( 'woocommerce_admin_order_totals_after_shipping', array( $this, 'woocommerce_admin_order_totals_after_shipping' ), 1 );
56
- add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'store_order_id' ), 1 );
57
- add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'store_order_id' ), 1 );
58
- add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'store_order_id' ), 1 );
59
- add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'store_order_id' ), 1 );
60
- add_action( 'woocommerce_order_status_failed_to_completed_notification', array( $this, 'store_order_id' ), 1 );
61
- add_action( 'woocommerce_order_status_completed_notification', array( $this, 'store_order_id' ), 1 );
62
- add_action( 'woocommerce_new_customer_note_notification', array( $this, 'store_order_id' ), 1 );
63
- add_action( 'wp_head', array( $this, 'generator' ) );
64
- add_filter( 'woocommerce_order_formatted_billing_address', array($this,'formatted_billing_address') , 10 , 2);
65
- add_filter( 'woocommerce_order_formatted_shipping_address', array($this,'formatted_shipping_address') , 10 , 2);
66
-
67
- if(@$_GET['page'] != 'woocommerce_saphali_s_l' && @$_GET['tab'] !=1 ) {
68
- // Hook in
69
- add_filter( 'woocommerce_checkout_fields' , array($this,'saphali_custom_override_checkout_fields') );
70
- add_filter( 'wp' , array($this,'wp') );
71
-
72
- add_filter( 'woocommerce_billing_fields', array($this,'saphali_custom_billing_fields'), 10, 1 );
73
- add_filter( 'woocommerce_shipping_fields', array($this,'saphali_custom_shipping_fields'), 10, 1 );
74
- add_filter( 'woocommerce_default_address_fields', array($this,'woocommerce_default_address_fields'), 10, 1 );
75
- //add_filter( 'woocommerce_get_country_locale', array($this,'woocommerce_get_country_locale'), 10, 1 );
76
- add_action('admin_init', array($this,'woocommerce_customer_meta_fields_action'), 20);
77
- add_action( 'personal_options_update', array($this,'woocommerce_save_customer_meta_fields_saphali') );
78
- add_action( 'edit_user_profile_update', array($this,'woocommerce_save_customer_meta_fields_saphali') );
79
- /* add_action( 'woocommerce_admin_order_data_after_billing_address', array($this,'woocommerce_admin_order_data_after_billing_address_s') );
80
- add_action( 'woocommerce_admin_order_data_after_shipping_address', array($this,'woocommerce_admin_order_data_after_shipping_address_s') ); */
81
- add_action( 'woocommerce_admin_order_data_after_order_details', array($this,'woocommerce_admin_order_data_after_order_details_s') );
82
-
83
- }
84
- add_filter( 'woocommerce_currencies', array($this,'add_inr_currency') , 11);
85
- add_filter( 'woocommerce_currency_symbol', array($this,'add_inr_currency_symbol') , 1, 2 );
86
- add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'checkout_update_order_meta' ), 99, 2 );
87
- $this->column_count_saphali = get_option('column_count_saphali');
88
- if(!empty($this->column_count_saphali)) {
89
- global $woocommerce_loop;
90
- $woocommerce_loop['columns'] = $this->column_count_saphali;
91
- add_action("wp_head", array($this,'print_script_columns'), 10, 1);
92
- add_filter("loop_shop_columns", array($this, 'print_columns'), 10, 1);
93
- add_filter("woocommerce_output_related_products_args", array($this, 'related_print_columns'), 10, 1);
94
- }
95
- if(is_admin()) {
96
- add_filter( 'woocommerce_admin_billing_fields', array($this,'woocommerce_admin_billing_fields'), 10, 1 );
97
- add_filter( 'woocommerce_admin_shipping_fields', array($this,'woocommerce_admin_shipping_fields'), 10, 1 );
98
- }
99
- }
100
- function formatted_billing_address($address, $order) {
101
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
102
- foreach ( array("billing") as $type )
103
- {
104
- if ( isset($billing_data[$type]) && is_array($billing_data[$type]))
105
- {
106
- foreach ( $billing_data[$type] as $key => $field ) {
107
-
108
- if (isset($field['public']) && $field['public'] ) {
109
- $address[str_replace($type . '_', '', $key)] = get_post_meta( $order->id, '_' . $key, true );
110
- if( !empty($address[str_replace($type . '_', '', $key)]) && ( strpos($key, 'new_fild') !== false) )
111
- echo '<label><strong>'. $field['label']. ':</strong></label> ' . $address[str_replace($type . '_', '', $key)].'<br />';
112
- }
113
- }
114
- }
115
- }
116
- return($address);
117
- }
118
- function formatted_shipping_address($address, $order) {
119
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
120
- if(is_array($billing_data["order"])) {
121
- foreach ( $billing_data["order"] as $key => $field ) {
122
- if (isset($field['show']) && !$field['show'] || $key == 'order_comments') continue;
123
- $address[ str_replace('order_', '', $key) ] = get_post_meta( $order->id, '_' . $key, true );
124
- if( !empty($address[ str_replace('order_', '', $key) ]) && ( strpos($key, 'new_fild') === false) )
125
- echo '<label><strong>'. $field['label']. ':</strong></label> ' . $address[ str_replace('order_', '', $key) ] . '<br />';
126
- }
127
- }
128
- foreach ( array( "shipping") as $type )
129
- {
130
- if ( isset($billing_data[$type]) && is_array($billing_data[$type]))
131
- {
132
- foreach ( $billing_data[$type] as $key => $field ) {
133
-
134
- if (isset($field['public']) && $field['public'] ) {
135
- $address[str_replace($type . '_', '', $key)] = get_post_meta( $order->id, '_' . $key, true );
136
- if( !empty($address[str_replace($type . '_', '', $key)]) && ( strpos($key, 'new_fild') === false) ) {
137
- echo '<label><strong>'. $field['label']. ':</strong></label> ' . $address[str_replace($type . '_', '', $key)].'<br />'; }
138
-
139
- }
140
- }
141
- }
142
- }
143
- return($address);
144
- }
145
- function woocommerce_admin_billing_fields($billing_fields) {
146
- if ( !version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) ) {
147
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
148
- if(is_array($billing_data["billing"])) {
149
- foreach ( $billing_data["billing"] as $key => $field ) {
150
- $key = str_replace('billing_', '', $key);
151
- if (isset($field['show']) && !$field['show'] || $key == 'order_comments') continue;
152
- if( strpos($key, 'new_fild') === false)
153
- $billing_fields[$key] = array(
154
- 'label' => $field['label'],
155
- 'show' => false
156
- );
157
- else
158
- $billing_fields[$key] = array(
159
- 'label' => $field['label'],
160
- 'show' => true
161
- );
162
- }
163
- }
164
- }
165
- return $billing_fields;
166
- }
167
- function woocommerce_admin_shipping_fields($shipping_fields) {
168
- if ( !version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) ) {
169
- $shipping_data = $this->woocommerce_get_customer_meta_fields_saphali();
170
- if(is_array($shipping_data["shipping"])) {
171
- foreach ( $shipping_data["shipping"] as $key => $field ) {
172
- $key = str_replace('shipping_', '', $key);
173
- if (isset($field['show']) && !$field['show'] || $key == 'order_comments') continue;
174
- if( strpos($key, 'new_fild') === false)
175
- $shipping_fields[$key] = array(
176
- 'label' => $field['label'],
177
- 'show' => false
178
- );
179
- else
180
- $shipping_fields[$key] = array(
181
- 'label' => $field['label'],
182
- 'show' => true
183
- );
184
- }
185
- }
186
- }
187
- return $shipping_fields;
188
- }
189
-
190
- public function wp( ) {
191
- if(function_exists('wc_edit_address_i18n')){
192
- global $wp;
193
- if(isset($wp->query_vars['edit-address']))
194
- add_filter( 'woocommerce_'.wc_edit_address_i18n( sanitize_key( $wp->query_vars['edit-address'] ), true ) .'_fields', array($this,'saphali_custom_edit_address_fields'), 10, 1 );
195
- }
196
- }
197
- public function checkout_update_order_meta( $order_id, $posted ) {
198
- if ( !version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) ) {
199
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
200
- if(is_array($billing_data["order"])) {
201
- foreach ( $billing_data["order"] as $key => $field ) {
202
- if (isset($field['show']) && !$field['show'] || $key == 'order_comments') continue;
203
- if(!empty($_POST[$key]))
204
- update_post_meta( $order_id, '_' . $key, $_POST[$key] );
205
- }
206
- }
207
- foreach ( array("billing", "shipping") as $type )
208
- {
209
- if ( isset($billing_data[$type]) && is_array($billing_data[$type]))
210
- {
211
- foreach ( $billing_data[$type] as $key => $field ) {
212
-
213
- if (isset($field['public']) && $field['public'] && !empty($_POST[$key])) {
214
- update_post_meta( $order_id, '_' . $key, $_POST[$key] );
215
- }
216
- }
217
- }
218
- }
219
- }
220
- }
221
- public function woocommerce_admin_order_totals_after_shipping($id) {
222
- if( apply_filters( 'woocommerce_currency', get_option('woocommerce_currency') ) == 'RUB' ) {
223
- ?>
224
- <script type="text/javascript">
225
- jQuery( function($){
226
- $('#woocommerce-order-totals').on( 'change', '#_order_tax, #_order_shipping_tax, #_cart_discount, #_order_discount', function() {
227
-
228
- var $this = $(this);
229
- var fields = $this.closest('.totals').find('input');
230
- var total = 0;
231
-
232
- fields.each(function(){
233
- if ( $(this).val() )
234
- total = total + parseFloat( $(this).val() );
235
- });
236
-
237
- var formatted_total = accounting.formatMoney( total, {
238
- symbol : woocommerce_writepanel_params.currency_format_symbol,
239
- decimal : woocommerce_writepanel_params.currency_format_decimal_sep,
240
- thousand : woocommerce_writepanel_params.currency_format_thousand_sep,
241
- precision : woocommerce_writepanel_params.currency_format_num_decimals,
242
- format : woocommerce_writepanel_params.currency_format
243
- } );
244
- $this.closest('.totals_group').find('span.inline_total').html( formatted_total );
245
-
246
- } );
247
- setTimeout(function() {$('span.inline_total').closest('.totals_group').find('input').change();}, 100);
248
- });
249
- </script>
250
- <?php
251
- }
252
- }
253
- public function load_plugin_textdomain() {
254
- load_plugin_textdomain( 'woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
255
- load_plugin_textdomain( 'saphali-woocommerce-lite', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
256
- }
257
- public function load_plugin_textdomain_th() {
258
- load_plugin_textdomain( 'saphali-woocommerce-lite', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
259
- }
260
- public function woocommerce_default_address_fields($locale) {
261
- $fieldss = get_option('woocommerce_saphali_filds_locate');
262
- if(is_array($fieldss))
263
- $locale = $fieldss;
264
- return $locale;
265
- }
266
- public function woocommerce_get_country_locale($locale) {
267
-
268
- return $locale;
269
- }
270
- public function generator() {
271
- echo "\n\n" . '<!-- Saphali Lite Version -->' . "\n" . '<meta name="generator" content="Saphali Lite ' . esc_attr( SAPHALI_LITE_VERSION ) . '" />' . "\n\n";
272
- }
273
- function woocommerce_customer_meta_fields_action() {
274
- add_action( 'show_user_profile', array($this,'woocommerce_customer_meta_fields_s') );
275
- add_action( 'edit_user_profile', array($this,'woocommerce_customer_meta_fields_s') );
276
- }
277
- function woocommerce_customer_meta_fields_s( $user ) {
278
- if ( ! current_user_can( 'manage_woocommerce' ) )
279
- return;
280
-
281
- $show_fields = $this->woocommerce_get_customer_meta_fields_saphali();
282
- if(!empty($show_fields["billing"])) {
283
- $show_field["billing"]['title'] = __('Customer Billing Address', 'woocommerce');
284
- $show_field["billing"]['fields'] = $show_fields["billing"];
285
- }
286
- if(!empty($show_fields["shipping"])) {
287
- $show_field["shipping"]['title'] = __('Customer Shipping Address', 'woocommerce');
288
- $show_field["shipping"]['fields'] = $show_fields["shipping"];
289
- }
290
- if(is_array($show_field)) {
291
- $count = 0; echo '<fieldset>';
292
- foreach( $show_field as $fieldset ) :
293
- if(!$count) echo '<h2>Дополнительные поля</h2>';
294
- $count++;
295
- ?>
296
- <h3><?php echo $fieldset['title']; ?></h3>
297
- <table class="form-table">
298
- <?php
299
- foreach( $fieldset['fields'] as $key => $field ) :
300
- ?>
301
- <tr>
302
- <th><label for="<?php echo $key; ?>"><?php echo $field['label']; ?></label></th>
303
- <td>
304
- <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/>
305
- <span class="description"><?php echo $field['description']; ?></span>
306
- </td>
307
- </tr>
308
- <?php
309
- endforeach;
310
- ?>
311
- </table>
312
- <?php
313
- endforeach;
314
- echo '</fieldset>';
315
- }
316
- }
317
- function woocommerce_saphali_admin_menu_s_l() {
318
- add_submenu_page('woocommerce', __('Настройки Saphali WC Lite', 'woocommerce'), __('Saphali WC Lite', 'woocommerce') , 'manage_woocommerce', 'woocommerce_saphali_s_l', array($this,'woocommerce_saphali_page_s_l'));
319
- }
320
- function add_inr_currency( $currencies ) {
321
- $currencies['UAH'] = __( 'Ukrainian hryvnia', 'saphali-woocommerce-lite' );
322
- $currencies['RUR'] = __( 'Russian ruble', 'saphali-woocommerce-lite' );
323
- if( version_compare( WOOCOMMERCE_VERSION, '2.5.2', '<' ) || SAPHALI_LITE_SYMBOL )
324
- $currencies['RUB'] = __( 'Russian ruble', 'saphali-woocommerce-lite' );
325
- $currencies['BYN'] = sprintf(__( 'Belarusian ruble%s', 'saphali-woocommerce-lite' ), __(' (new)', 'saphali-woocommerce-lite'));
326
- $currencies['BYR'] = sprintf(__( 'Belarusian ruble%s', 'saphali-woocommerce-lite' ), '');
327
- $currencies['AMD'] = __( 'Armenian dram (Դրամ)', 'saphali-woocommerce-lite' );
328
- $currencies['KGS'] = __( 'Киргизский сом', 'saphali-woocommerce-lite' );
329
- $currencies['KZT'] = __( 'Казахстанский тенге ', 'saphali-woocommerce-lite' );
330
- $currencies['UZS'] = __( 'Узбекский сум', 'saphali-woocommerce-lite' );
331
- $currencies['LTL'] = __( 'Lithuanian Litas', 'saphali-woocommerce-lite' );
332
- return $currencies;
333
- }
334
- function add_inr_currency_symbol( $symbol , $currency ) {
335
- if(empty($currency))
336
- $currency = get_option( 'woocommerce_currency' );
337
- if(isset($currency)) {
338
- if( version_compare( WOOCOMMERCE_VERSION, '2.5.2', '<' ) || SAPHALI_LITE_SYMBOL )
339
- switch( $currency ) {
340
- case 'UAH': $symbol = '&#x433;&#x440;&#x43D;.'; break;
341
- case 'RUB': $symbol = '<span class=rur >&#x440;<span>&#x443;&#x431;.</span></span>'; break;
342
- case 'RUR': $symbol = '&#x440;&#x443;&#x431;.'; break;
343
- case 'BYN': $symbol = '&#x440;&#x443;&#x431;.'; break;
344
- case 'BYR': $symbol = '&#x440;&#x443;&#x431;.'; break;
345
- case 'AMD': $symbol = '&#x534;'; break;
346
- case 'KGS': $symbol = 'сом'; break;
347
- case 'KZT': $symbol = '&#x20B8;'; break;
348
- case 'UZS': $symbol = '&#x441;&#x45E;&#x43C;'; break;
349
- case 'LTL': $symbol = 'lt.'; break;
350
- }
351
- else
352
- switch( $currency ) {
353
- case 'UAH': $symbol = '&#x433;&#x440;&#x43D;.'; break;
354
- case 'RUR': $symbol = '&#x440;&#x443;&#x431;.'; break;
355
- case 'BYN': $symbol = '&#x440;&#x443;&#x431;.'; break;
356
- case 'BYR': $symbol = '&#x440;&#x443;&#x431;.'; break;
357
- case 'AMD': $symbol = '&#x534;'; break;
358
- case 'KGS': $symbol = 'сом'; break;
359
- case 'KZT': $symbol = '&#x20B8;'; break;
360
- case 'UZS': $symbol = '&#x441;&#x45E;&#x43C;'; break;
361
- case 'LTL': $symbol = 'lt.'; break;
362
- }
363
- }
364
- return $symbol;
365
- }
366
- function admin_enqueue_scripts_page_saphali() {
367
- global $woocommerce;
368
- $plugin_url = plugins_url( basename( plugin_dir_path(__FILE__) ), basename( __FILE__ ) );
369
- if( isset($_GET['page']) && $_GET['page'] == 'woocommerce_saphali_s_l' && (isset($_GET['tab']) && $_GET['tab'] ==1) )
370
- wp_enqueue_script( 'tablednd', $plugin_url. '/js/jquery.tablednd.0.5.js', array('jquery'), $woocommerce->version );
371
- }
372
- function woocommerce_saphali_page_s_l () {
373
- ?>
374
- <div class="wrap woocommerce"><div class="icon32 icon32-woocommerce-reports" id="icon-woocommerce"><br /></div>
375
- <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
376
- Настройки Saphali WC
377
- </h2>
378
- <ul class="subsubsub">
379
-
380
- <li><a href="admin.php?page=woocommerce_saphali_s_l" <?php if(empty($_GET["tab"])) echo 'class="current"';?>><span color="red">Дополнительная информация</span></a> | </li>
381
- <li><a href="admin.php?page=woocommerce_saphali_s_l&tab=1" <?php if(!empty($_GET["tab"]) && $_GET["tab"] == 1) echo 'class="current"';?>>Управление полями</a> | </li>
382
- <li><a href="admin.php?page=woocommerce_saphali_s_l&tab=2" <?php if(!empty($_GET["tab"]) && $_GET["tab"] == 2) echo 'class="current"';?>>Число колонок в каталоге</a></li>
383
-
384
- </ul>
385
- <?php if( empty($_GET["tab"]) ) {?>
386
- <div class="clear"></div>
387
- <h2 class="woo-nav-tab-wrapper">Дополнительная информация</h2>
388
- <?php include_once (SAPHALI_PLUGIN_DIR_PATH . 'go_pro.php'); } elseif($_GET["tab"] == 2) {?>
389
- <div class="clear"></div>
390
- <h2 class="woo-nav-tab-wrapper">Число колонок в каталоге товаров и в рубриках</h2>
391
- <?php include_once (SAPHALI_PLUGIN_DIR_PATH . 'count-column.php'); } elseif($_GET["tab"] == 1) {
392
- global $woocommerce;
393
- if ( empty( $woocommerce->checkout ) ) {
394
-
395
- if ( version_compare( WOOCOMMERCE_VERSION, '2.0', '<' ) ) {
396
- include_once( WP_PLUGIN_DIR . '/' . $woocommerce->template_url. 'classes/class-wc-checkout.php' );
397
- } elseif ( !version_compare( WOOCOMMERCE_VERSION, '2.3', '<' ) ) {
398
- include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/class-wc-autoloader.php' );
399
- $load = new WC_Autoloader();
400
- if(!class_exists('WC_Customer')) $load->autoload( 'WC_Customer' ); $load->autoload( 'WC_Checkout' ); if ( !version_compare( WOOCOMMERCE_VERSION, '2.2', '<' ) ) { include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/abstracts/abstract-wc-session.php' ); include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/class-wc-session-handler.php' ); $woocommerce->session = new WC_Session_Handler();} else {
401
- $woocommerce->autoload( 'WC_Session' );
402
- $woocommerce->autoload( 'WC_Session_Handler' );
403
- }
404
- } else {
405
- if(!class_exists('WC_Customer')) $woocommerce->autoload( 'WC_Customer' ); $woocommerce->autoload( 'WC_Checkout' ); if ( !version_compare( WOOCOMMERCE_VERSION, '2.2', '<' ) ) { include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.2/','compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/abstracts/abstract-wc-session.php' ); include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.2/','compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/class-wc-session-handler.php' ); $woocommerce->session = new WC_Session_Handler();} else {
406
- $woocommerce->autoload( 'WC_Session' );
407
- if ( !version_compare( WOOCOMMERCE_VERSION, '2.1', '<' ))
408
- $woocommerce->autoload( 'WC_Session_Handler' );
409
- }
410
- }
411
- if(class_exists('WC_Checkout')) {
412
- if(class_exists('WC_Customer')) $woocommerce->customer = new WC_Customer();
413
- $f = new WC_Checkout();
414
- }
415
- }
416
- else $f = $woocommerce->checkout;
417
- if($_POST){
418
- if(@$_POST["reset"] != 'All') {
419
- // Управление новыми полями
420
-
421
- if(@is_array($_POST["billing"]["new_fild"])) {
422
- foreach($_POST["billing"]["new_fild"] as $k_nf => $v_nf) {
423
- if($k_nf == 'name') {
424
- foreach($v_nf as $v_nf_f) {
425
- $new_fild = $v_nf_f;
426
- }
427
- }
428
- else {
429
- if(is_array($v_nf) )
430
- foreach($v_nf as $k_nf_f => $v_nf_f) {
431
- if($k_nf == 'class' ) {
432
- $v_nf_f = array ( $v_nf_f );
433
- $addFild["billing"][$new_fild][$k_nf] = $v_nf_f;
434
- } else $addFild["billing"][$new_fild][$k_nf] = $v_nf_f;
435
- //$addFild["billing"][$new_fild[$k_nf_f]]['add_new'] = true;
436
- }
437
- if($k_nf == 'type' && !is_array($v_nf) || $k_nf == 'options') {
438
- $addFild["billing"][$new_fild][$k_nf] = $v_nf;
439
- }
440
- }
441
- }
442
- unset($_POST["billing"]["new_fild"]);
443
- unset($new_fild);
444
- }
445
- if(@is_array($_POST["shipping"]["new_fild"])) {
446
- foreach($_POST["shipping"]["new_fild"] as $k_nf => $v_nf) {
447
- if($k_nf == 'name')
448
- foreach($v_nf as $v_nf_f)
449
- $new_fild[] = $v_nf_f;
450
- else {
451
- foreach($v_nf as $k_nf_f => $v_nf_f) {
452
- if($k_nf == 'class') {
453
- $v_nf_f = array ( $v_nf_f );
454
- $addFild["shipping"][$new_fild[$k_nf_f]][$k_nf] = $v_nf_f;
455
- } else $addFild["shipping"][$new_fild[$k_nf_f]][$k_nf] = $v_nf_f;
456
- //$addFild["shipping"][$new_fild[$k_nf_f]]['add_new'] = true;
457
- }
458
- }
459
- }
460
- unset($_POST["shipping"]["new_fild"]);
461
- unset($new_fild);
462
- }
463
- if(@is_array($_POST["order"]["new_fild"])) {
464
- foreach($_POST["order"]["new_fild"] as $k_nf => $v_nf) {
465
- if($k_nf == 'name')
466
- foreach($v_nf as $v_nf_f)
467
- $new_fild[] = $v_nf_f;
468
- else {
469
- foreach($v_nf as $k_nf_f => $v_nf_f) {
470
- if($k_nf == 'class') {
471
- $v_nf_f = array ( $v_nf_f );
472
- $addFild["order"][$new_fild[$k_nf_f]][$k_nf] = $v_nf_f;
473
- } else $addFild["order"][$new_fild[$k_nf_f]][$k_nf] = $v_nf_f;
474
- //$addFild["order"][$new_fild[$k_nf_f]]['add_new'] = true;
475
- }
476
- }
477
- }
478
- unset($_POST["order"]["new_fild"]);
479
- }
480
- //END
481
- $filds = $f->checkout_fields;
482
-
483
- if(is_array($filds["billing"])) {
484
- if(!is_array($addFild["billing"])) $addFild["billing"] = array();
485
- if(!is_array($_POST["billing"])) $_POST["billing"] = array();
486
- $filds["billing"] = array_merge($filds["billing"] , $_POST["billing"], $addFild["billing"]);
487
-
488
- foreach($filds["billing"] as $key_post => $value_post) {
489
-
490
- if( !isset($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"]);
491
-
492
-
493
- if(@$filds["billing"][$key_post]['public'] != 'on') {
494
- $filds_new["billing"][$filds["billing"][$key_post]["order"]][$key_post]["public"] = false;
495
- $fild_remove_filter["billing"][] = $key_post;
496
- } else {$filds_new["billing"][$filds["billing"][$key_post]["order"]][$key_post]["public"] = true;}
497
-
498
-
499
- foreach($value_post as $k_post=> $v_post){
500
- if( 'on' == $v_post ) {
501
- $filds["billing"][$key_post][$k_post] = true;
502
- $value_post[$k_post] = true;
503
- } elseif(in_array($k_post, array('public','clear','required'))) { $filds["billing"][$key_post][$k_post] = false; $value_post[$k_post] = false; if(!$filds["billing"][$key_post][$k_post] && $k_post == 'public') unset($filds["billing"][$key_post][$k_post]); }
504
- }
505
- $filds_new["billing"][$filds["billing"][$key_post]["order"]][$key_post] = $value_post;
506
-
507
- unset($_POST["billing"][$key_post]);
508
- }
509
-
510
- }
511
- if(is_array($filds["shipping"])) {
512
- if(!is_array($addFild["shipping"])) $addFild["shipping"] = array();
513
- if(!is_array($_POST["shipping"])) $_POST["shipping"] = array();
514
- $filds["shipping"] = array_merge($filds["shipping"] , $_POST["shipping"], $addFild["shipping"]);
515
- foreach($filds["shipping"] as $key_post => $value_post) {
516
-
517
- if( !isset($f->checkout_fields["shipping"][$key_post]['type']) ) unset($filds["shipping"][$key_post]['type'], $value_post["type"]);
518
-
519
- if($filds["shipping"][$key_post]['public'] != 'on') {
520
- $filds_new["shipping"][$filds["shipping"][$key_post]["order"]][$key_post]["public"] = false;
521
- $fild_remove_filter["shipping"][] = $key_post;
522
- } else {$filds_new["shipping"][$filds["shipping"][$key_post]["order"]][$key_post]["public"] = true;}
523
-
524
- foreach($value_post as $k_post=> $v_post){
525
- if( 'on' == $v_post ) {
526
- $filds["shipping"][$key_post][$k_post] = true;
527
- $value_post[$k_post] = true;
528
- } elseif(in_array($k_post, array('public','clear','required'))) { $filds["shipping"][$key_post][$k_post] = false; $value_post[$k_post] = false; if(!$filds["shipping"][$key_post][$k_post] && $k_post == 'public') unset($filds["shipping"][$key_post][$k_post]); }
529
- }
530
- $filds_new["shipping"][$filds["shipping"][$key_post]["order"]][$key_post] = $value_post;
531
- unset($_POST["shipping"][$key_post]);
532
- }
533
- }
534
- if(is_array($filds["order"])) {
535
- if(!is_array($addFild["order"])) $addFild["order"] = array();
536
- if(!is_array($_POST["order"])) $_POST["order"] = array();
537
- $filds["order"] = array_merge($filds["order"] , $_POST["order"], $addFild["order"]);
538
-
539
- foreach($filds["order"] as $key_post => $value_post) {
540
-
541
- if($filds["order"][$key_post]['public'] != 'on') {
542
- $filds_new["order"][$filds["order"][$key_post]["order"]][$key_post]["public"] = false;
543
- $fild_remove_filter["order"][] = $key_post;
544
- } else {$filds_new["order"][$filds["order"][$key_post]["order"]][$key_post]["public"] = true;}
545
-
546
- foreach($value_post as $k_post=> $v_post){
547
- if( 'on' == $v_post ) {
548
- $filds["order"][$key_post][$k_post] = true;
549
- $value_post[$k_post] = true;
550
- } elseif(in_array($k_post, array('public','clear','required'))) { $filds["order"][$key_post][$k_post] = false; $value_post[$k_post] = false; if(!$filds["order"][$key_post][$k_post] && $k_post == 'public') unset($filds["order"][$key_post][$k_post]); }
551
- }
552
-
553
- $filds_new["order"][$filds["order"][$key_post]["order"]][$key_post] = $value_post;
554
-
555
- unset($_POST["order"][$key_post]);
556
- }
557
- }
558
-
559
- //END Управление публикацией
560
- $filds_finish["billing"] = $filds_finish["shipping"] = $filds_finish["order"] = array();
561
-
562
- for($i = 0; $i<count($filds_new["billing"]); $i++) {
563
- if(isset($filds_new["billing"][$i]))
564
- $filds_finish["billing"] = $filds_finish["billing"] + $filds_new["billing"][$i];
565
- }
566
- for($i = 0; $i<count($filds_new["shipping"]); $i++) {
567
- if(isset($filds_new["shipping"][$i]))
568
- $filds_finish["shipping"] = $filds_finish["shipping"] + $filds_new["shipping"][$i];
569
- }
570
- for($i = 0; $i<count($filds_new["order"]); $i++) {
571
- if(isset($filds_new["order"][$i]))
572
- $filds_finish["order"] = $filds_finish["order"] + $filds_new["order"][$i];
573
- }
574
-
575
- $filds_finish_filter = $filds_finish;
576
- if(is_array($fild_remove_filter["billing"])) {
577
- foreach($fild_remove_filter["billing"] as $v_filt){
578
- unset($filds_finish_filter["billing"][$v_filt]);
579
- }
580
- }
581
- if(is_array($fild_remove_filter["shipping"])) {
582
- foreach($fild_remove_filter["shipping"] as $v_filt){
583
- unset($filds_finish_filter["shipping"][$v_filt]);
584
- }
585
- }
586
- if(is_array($fild_remove_filter["order"])) {
587
- foreach($fild_remove_filter["order"] as $v_filt){
588
- unset($filds_finish_filter["order"][$v_filt]);
589
- }
590
- }
591
- if(!update_option('woocommerce_saphali_filds',$filds_finish))add_option('woocommerce_saphali_filds',$filds_finish);
592
- if(!update_option('woocommerce_saphali_filds_filters',$filds_finish_filter))add_option('woocommerce_saphali_filds_filters',$filds_finish_filter);
593
- foreach($filds_finish_filter['billing'] as $k_f => $v_f) {
594
- $new_key = str_replace('billing_', '' , $k_f);
595
- if(in_array($new_key, array('country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ) ))
596
- $locate[$new_key] = $v_f;
597
- elseif(in_array(str_replace('shipping_', '' , $k_f), array('country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ) )) {
598
- $locate[$new_key] = $filds_finish_filter['shipping'][$k_f];
599
- }
600
- }
601
- if(!update_option('woocommerce_saphali_filds_locate',$locate))add_option('woocommerce_saphali_filds_locate',$locate);
602
- } else {
603
- delete_option('woocommerce_saphali_filds');
604
- delete_option('woocommerce_saphali_filds_filters');
605
- delete_option('woocommerce_saphali_filds_locate');
606
- }
607
- }
608
-
609
- ?>
610
- <div class="clear"></div>
611
- <h3 class="nav-tab-wrapper woo-nav-tab-wrapper" style="text-align: center;">Управление полями на странице заказа и на странице профиля</h3>
612
- <?php if($_POST && @$_POST["reset"] != 'All') { ?><div class="updated" id="message"><p>Настройки сохранены</p></div><?php } ?>
613
- <h2 align="center">Реквизиты оплаты</h2>
614
- <form action="" method="post">
615
- <table class="wp-list-table widefat fixed posts" cellspacing="0">
616
- <thead>
617
- <tr>
618
- <th width="130px">Название<img class="help_tip" data-tip="Название поля должно быть уни&shy;ка&shy;ль&shy;ным (не должно повторяться)." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
619
- <th width="130px">Заголовок</th>
620
- <th width="130px">Текст в поле</th>
621
- <th width="35px">Clear<img class="help_tip" data-tip="Указывает на то, что следующее поле за текущим, будет начинаться с новой строки." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /> </th>
622
- <th width="130px">Класс поля<img class="help_tip" data-tip="<h3 style='margin:0;padding:0'>Задает стиль текущего поля</h3><ul style='text-align: left;'><li><span style='color: #000'>form-row-first</span>&nbsp;&ndash;&nbsp;первый в строке;</li><li><span style='color: #000'>form-row-last</span>&nbsp;&ndash;&nbsp;последний в строке.</li></ul><hr /><span style='color: #000'>ЕСЛИ ОСТАВИТЬ ПУСТЫМ</span>, то поле будет отображаться на всю ширину. Соответственно, в предыдущем поле (которое выше) нужно отметить &laquo;Clear&raquo;." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
623
- <th width="40px">Тип поля</th>
624
- <th width="40px">Обя&shy;за&shy;те&shy;ль&shy;ное</th>
625
-
626
- <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
627
-
628
- <th width="65px">Удалить/До&shy;ба&shy;вить</th>
629
- </tr>
630
- </thead>
631
- <tfoot>
632
- <tr>
633
- <th>Название</th>
634
- <th>Заголовок</th>
635
- <th>Текст в поле</th>
636
- <th width="35px">Clear<img class="help_tip" data-tip="Указывает на то, что следующее поле за текущим, будет начинаться с новой строки." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /> </th>
637
- <th>Класс поля</th>
638
- <th width="40px">Тип поля</th>
639
- <th width="40px">Обя&shy;за&shy;те&shy;ль&shy;ное</th>
640
-
641
- <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
642
-
643
- <th>Удалить/До&shy;ба&shy;вить</th>
644
- </tr>
645
- </tfoot>
646
- <tbody id="the-list" class="myTable">
647
- <?php
648
-
649
- $count = 0;
650
-
651
- $checkout_fields = get_option('woocommerce_saphali_filds');
652
-
653
- if( isset($checkout_fields["billing"]) && is_array($checkout_fields["billing"])) $f->checkout_fields["billing"] = $checkout_fields["billing"];
654
- if( isset($f) )
655
- foreach($f->checkout_fields["billing"] as $key => $value) {
656
- if(empty($value['public']) && !is_array($checkout_fields["billing"])) $value['public'] = true;
657
- ?>
658
- <tr>
659
- <td> <input disabled value='<?php echo $key?>' type="text" name="billing[<?php echo $key?>][name]" /></td>
660
- <td><input value='<?php echo $value['label']?>' type="text" name="billing[<?php echo $key?>][label]" /></td>
661
- <td<?php if(isset($value['type']) && $value['type'] == 'select') {echo ' class="option-area"';} ?>><?php if(!isset($value['type']) || isset($value['type']) && $value['type'] != 'select') { ?><input value='<?php if(isset( $value['placeholder'] )) echo $value['placeholder']; ?>' type="text" name="billing[<?php echo $key?>][placeholder]" /><?php } else {
662
- if( isset($value['options']) && is_array($value['options']) ) {
663
- foreach($value['options'] as $key_option => $val_option) {?>
664
- <span><input id="options" type="text" name="billing[<?php echo $key?>][options][<?php echo $key_option; ?>]" value="<?php echo $val_option?>" /> <span class="delete-option" style="cursor:pointer;border:1px solid">Удалить</span></span><br />
665
-
666
- <?php } ?>
667
- <div class="button add_option" rel="<?php echo $key; ?>">Добавить еще</div>
668
- <?php
669
- }
670
-
671
- } ?></td>
672
- <td><input <?php if(isset($value['clear']) && $value['clear']) echo 'checked'?> class="<?php echo isset($value['clear']) ? $value['clear'] : '' ;?>" type="checkbox" name="billing[<?php echo $key?>][clear]" /></td>
673
- <td><?php if(isset($value['class']) && is_array($value['class'])) { foreach($value['class'] as $v_class) { ?>
674
- <input value='<?php echo $v_class;?>' type="text" name="billing[<?php echo $key?>][class][]" /> <?php } } else { ?>
675
- <input value='' type="text" name="billing[<?php echo $key?>][class][]" /> <?php
676
- } ?></td>
677
- <td>
678
- Select <input <?php if(isset($value['type']) && $value['type'] == 'select') echo 'checked'?> type="radio" name="billing[<?php echo $key?>][type]" value="select" /><br />
679
- Checkbox <input <?php if(isset($value['type']) && $value['type'] == 'checkbox') echo 'checked'?> type="radio" name="billing[<?php echo $key?>][type]" value="checkbox" /><br />
680
- Textarea <input <?php if(isset($value['type']) && $value['type'] == 'textarea') echo 'checked'?> type="radio" name="billing[<?php echo $key?>][type]" value="textarea" /><br />
681
- <?php echo (!isset($value['type']) || $value['type'] == 'select'|| $value['type'] == 'checkbox'|| $value['type'] == 'textarea') ? 'Text' : $value['type']; ?> <input <?php if(isset($value['type']) && $value['type'] == $value['type'] && $value['type'] != 'select'&& $value['type'] != 'textarea'&& $value['type'] != 'checkbox') echo 'checked'?> type="radio" name="billing[<?php echo $key?>][type]" value="<?php if( isset($value['type']) && $value['type'] != 'select' && $value['type'] != 'textarea'&& $value['type'] != 'checkbox') echo $value['type']; ?>" />
682
- </td>
683
- <td><input <?php if( isset($value['required'] ) && $value['required']) echo 'checked'?> type="checkbox" name="billing[<?php echo $key?>][required]" /></td>
684
- <td><input <?php if(isset($value['public']) && $value['public']) echo 'checked';?> type="checkbox" name="billing[<?php echo $key?>][public]" /></td>
685
-
686
- <td><input rel="sort_order" id="order_count" type="hidden" name="billing[<?php echo $key?>][order]" value="<?php echo $count?>" />
687
- <input type="button" class="button" id="billing_delete" value="Удалить -"/></td>
688
- </tr>
689
- <?php $count++;
690
- }
691
- ?>
692
- <tr class="nodrop nodrag">
693
- <td></td>
694
- <td></td>
695
- <td></td>
696
- <td></td>
697
- <td></td>
698
- <td></td>
699
-
700
- <td></td>
701
-
702
- <td><input type="button" class="button" id="billing" value="Добавить +"/></td>
703
- </tr>
704
- </tbody>
705
- </table>
706
-
707
- <h2 align="center">Реквизиты доставки</h2>
708
- <table class="wp-list-table widefat fixed posts" cellspacing="0">
709
- <thead>
710
- <tr>
711
- <th width="130px">Название<img class="help_tip" data-tip="Название поля должно быть уни&shy;ка&shy;ль&shy;ным (не должно повторяться)." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
712
- <th width="130px">Заголовок</th>
713
- <th width="130px">Текст в поле</th>
714
- <th width="35px">Clear<img class="help_tip" data-tip="Указывает на то, что следующее поле за текущим, будет начинаться с новой строки." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /> </th>
715
- <th width="130px">Класс поля<img class="help_tip" data-tip="<h3 style='margin:0;padding:0'>Задает стиль текущего поля</h3><ul style='text-align: left;'><li><span style='color: #000'>form-row-first</span>&nbsp;&ndash;&nbsp;первый в строке;</li><li><span style='color: #000'>form-row-last</span>&nbsp;&ndash;&nbsp;последний в строке.</li></ul><hr /><span style='color: #000'>ЕСЛИ ОСТАВИТЬ ПУСТЫМ</span>, то поле будет отображаться на всю ширину. Соответственно, в предыдущем поле (которое выше) нужно отметить &laquo;Clear&raquo;." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
716
- <th width="40px">Обя&shy;за&shy;те&shy;ль&shy;ное</th>
717
-
718
- <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
719
-
720
- <th width="65px">Удалить/До&shy;ба&shy;вить</th>
721
- </tr>
722
- </thead>
723
- <tfoot>
724
- <tr>
725
- <th>Название</th>
726
- <th>Заголовок</th>
727
- <th>Текст в поле</th>
728
- <th width="56px">Clear<img class="help_tip" data-tip="Указывает на то, что следующее поле за текущим, будет начинаться с новой строки." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /> </th>
729
- <th>Класс поля</th>
730
- <th width="40px">Обя&shy;за&shy;те&shy;ль&shy;ное</th>
731
-
732
- <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
733
-
734
- <th>Удалить/До&shy;ба&shy;вить</th>
735
- </tr>
736
- </tfoot>
737
- <tbody id="the-list" class="myTable">
738
- <?php $count = 0;
739
- if(isset($checkout_fields["shipping"]) && is_array($checkout_fields["shipping"])) $f->checkout_fields["shipping"] = $checkout_fields["shipping"];
740
- if( isset( $f->checkout_fields["shipping"] ) )
741
- foreach($f->checkout_fields["shipping"] as $key => $value) {
742
- if( empty($value['public']) && !is_array($checkout_fields["shipping"]) ) $value['public'] = true;
743
- ?>
744
- <tr>
745
- <td><input disabled value=<?php echo $key?> type="text" name="shipping[<?php echo $key?>][name]" /></td>
746
- <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>
747
- <td><input value='<?php if(isset( $value['placeholder'] )) echo $value['placeholder']; ?>' type="text" name="shipping[<?php echo $key?>][placeholder]" /></td>
748
- <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>
749
- <td><?php if( isset($value['class']) && is_array($value['class']) ) { foreach($value['class'] as $v_class) { ?>
750
-
751
- <input value='<?php echo $v_class;?>' type="text" name="shipping[<?php echo $key?>][class][]" /> <?php } } else { ?>
752
- <input value='' type="text" name="shipping[<?php echo $key?>][class][]" /> <?php
753
- } ?></td>
754
- <td><input <?php if(isset($value['required']) && $value['required']) echo 'checked'?> type="checkbox" name="shipping[<?php echo $key?>][required]" /></td>
755
- <td><input <?php if(isset($value['public']) && $value['public']) echo 'checked';?> type="checkbox" name="shipping[<?php echo $key?>][public]" /></td>
756
-
757
- <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="Удалить -"/>
758
- <?php
759
- if( isset($value['options']) && is_array($value['options']) ) {
760
- foreach($value['options'] as $key_option => $val_option) {?>
761
- <input id="options" type="hidden" name="shipping[<?php echo $key?>][options][<?php echo $key_option; ?>]" value="<?php echo $val_option?>" />
762
- <?php }
763
- } ?>
764
- </td>
765
- </tr>
766
- <?php $count++;
767
- }
768
- ?>
769
- <tr class="nodrop nodrag">
770
- <td></td>
771
- <td></td>
772
- <td></td>
773
-
774
- <td></td>
775
- <td></td>
776
- <td></td>
777
- <td></td>
778
-
779
- <td><input type="button" class="button" id="shipping" value="Добавить +"/></td>
780
- </tr>
781
-
782
- </tbody>
783
- </table>
784
- <br />
785
- <h2 align="center">Дополнительные поля</h2>
786
- <table class="wp-list-table widefat fixed posts" cellspacing="0">
787
- <thead>
788
- <tr>
789
- <th width="130px">Название<img class="help_tip" data-tip="Название поля должно быть уни&shy;ка&shy;ль&shy;ным (не должно повторяться)." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
790
- <th width="130px">Заголовок</th>
791
- <th width="130px">Текст в поле</th>
792
- <th width="130px">Класс поля</th>
793
- <th width="130px">Тип поля</th>
794
- <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
795
-
796
- <th width="65px">Удалить/До&shy;ба&shy;вить</th>
797
- </tr>
798
- </thead>
799
- <tfoot>
800
- <tr>
801
- <th>Название</th>
802
- <th>Заголовок</th>
803
- <th>Текст в поле</th>
804
- <th>Класс поля</th>
805
- <th>Тип поля</th>
806
- <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
807
-
808
- <th>Удалить/До&shy;ба&shy;вить</th>
809
- </tr>
810
- </tfoot>
811
- <tbody id="the-list" class="myTable">
812
- <?php $count = 0;
813
- if(isset($checkout_fields["order"]) && is_array($checkout_fields["order"])) $f->checkout_fields["order"] = $checkout_fields["order"];
814
- if(isset($f->checkout_fields["order"]) )
815
- foreach($f->checkout_fields["order"] as $key => $value) {
816
- if(empty($value['public']) && !is_array($checkout_fields["order"])) $value['public'] = true;
817
- ?>
818
- <tr>
819
- <td><input disabled value=<?php echo $key?> type="text" name="order[<?php echo $key?>][name]" /></td>
820
- <td><input value='<?php echo $value['label']?>' type="text" name="order[<?php echo $key?>][label]" /></td>
821
- <td><input value='<?php echo $value['placeholder']?>' type="text" name="order[<?php echo $key?>][placeholder]" /></td>
822
-
823
- <td><?php if(isset($value['class']) && is_array($value['class'])) { foreach($value['class'] as $v_class) { ?>
824
-
825
- <input value='<?php echo $v_class;?>' type="text" name="order[<?php echo $key?>][class][]" /> <?php } } else { ?>
826
- <input value='' type="text" name="order[<?php echo $key?>][class][]" /> <?php
827
- } ?></td>
828
- <td><input value='<?php echo $value['type']?>' type="text" name="order[<?php echo $key?>][type]" /></td>
829
- <td><input <?php if($value['public']) echo 'checked';?> type="checkbox" name="order[<?php echo $key?>][public]" /></td>
830
-
831
- <td><input id="order_count" rel="sort_order" type="hidden" name="order[<?php echo $key?>][order]" value="<?php echo $count?>" /><input type="button" class="button" id="billing_delete" value="Удалить -"/>
832
- <?php
833
- if( isset($value['options']) && is_array($value['options']) ) {
834
- foreach($value['options'] as $key_option => $val_option) {?>
835
- <input id="options" type="hidden" name="order[<?php echo $key?>][options][<?php echo $key_option; ?>]" value="<?php echo $val_option?>" />
836
- <?php }
837
- } ?>
838
- </td>
839
- </tr>
840
- <?php $count++;
841
- }
842
- ?>
843
- <tr class="nodrop nodrag">
844
- <td></td>
845
- <td></td>
846
- <td></td>
847
- <td></td>
848
- <td></td>
849
- <td></td>
850
-
851
-
852
- <td><input type="button" class="button" id="order" value="Добавить +"/></td>
853
- </tr>
854
- </tbody>
855
- </table><br />
856
- <input type="submit" class="button alignleft" value="Сохранить"/>
857
- </form>
858
- <form action="" method="post">
859
- <input type="hidden" name="reset" value="All"/>
860
- <input type="submit" class="button alignright" value="Восстановить поля по умолчанию"/>
861
- </form>
862
- <style type="text/css">
863
- #tiptip_content{font-size:11px;color:#fff;padding:4px 8px;background:#a2678c;border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;box-shadow:1px 1px 3px rgba(0,0,0,0.1);-webkit-box-shadow:1px 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:1px 1px 3px rgba(0,0,0,0.1);text-align:center}#tiptip_content code{background:#855c76;padding:1px}#tiptip_arrow,#tiptip_arrow_inner{position:absolute;border-color:transparent;border-style:solid;border-width:6px;height:0;width:0}#tiptip_holder.tip_top #tiptip_arrow_inner{margin-top:-7px;margin-left:-6px;border-top-color:#a2678c}#tiptip_holder.tip_bottom #tiptip_arrow_inner{margin-top:-5px;margin-left:-6px;border-bottom-color:#a2678c}#tiptip_holder.tip_right #tiptip_arrow_inner{margin-top:-6px;margin-left:-5px;border-right-color:#a2678c}#tiptip_holder.tip_left #tiptip_arrow_inner{margin-top:-6px;margin-left:-7px;border-left-color:#a2678c}img.help_tip{vertical-align:middle;margin:0 0 0 3px}#tiptip_holder{display:none;position:absolute;top:0;left:0;z-index:99999}#tiptip_holder.tip_top{padding-bottom:5px}#tiptip_holder.tip_bottom{padding-top:5px}#tiptip_holder.tip_right{padding-left:5px}#tiptip_holder.tip_left{padding-right:5px}#tiptip_content{font-size:11px;color:#fff;padding:4px 8px;background:#a2678c;border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;box-shadow:1px 1px 3px rgba(0,0,0,0.1);-webkit-box-shadow:1px 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:1px 1px 3px rgba(0,0,0,0.1);text-align:center}#tiptip_content code{background:#855c76;padding:1px}#tiptip_arrow,#tiptip_arrow_inner{position:absolute;border-color:transparent;border-style:solid;border-width:6px;height:0;width:0}#tiptip_holder.tip_top #tiptip_arrow_inner{margin-top:-7px;margin-left:-6px;border-top-color:#a2678c}#tiptip_holder.tip_bottom #tiptip_arrow_inner{margin-top:-5px;margin-left:-6px;border-bottom-color:#a2678c}#tiptip_holder.tip_right #tiptip_arrow_inner{margin-top:-6px;margin-left:-5px;border-right-color:#a2678c}#tiptip_holder.tip_left #tiptip_arrow_inner{margin-top:-6px;margin-left:-7px;border-left-color:#a2678c}
864
- input[disabled="disabled"], input[disabled=""] {
865
- background:none repeat scroll 0 0 #EAEAEA !important;
866
- color:#636060 !important;
867
- }
868
-
869
- </style>
870
- <script type="text/javascript">
871
- (function($){$.fn.tipTip=function(options){var defaults={activation:"hover",keepAlive:false,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:false,enter:function(){},exit:function(){}};var opts=$.extend(defaults,options);if($("#tiptip_holder").length<=0){var tiptip_holder=$('<div id="tiptip_holder" style="max-width:'+opts.maxWidth+';"></div>');var tiptip_content=$('<div id="tiptip_content"></div>');var tiptip_arrow=$('<div id="tiptip_arrow"></div>');$("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="tiptip_arrow_inner"></div>')))}else{var tiptip_holder=$("#tiptip_holder");var tiptip_content=$("#tiptip_content");var tiptip_arrow=$("#tiptip_arrow")}return this.each(function(){var org_elem=$(this);if(opts.content){var org_title=opts.content}else{var org_title=org_elem.attr(opts.attribute)}if(org_title!=""){if(!opts.content){org_elem.removeAttr(opts.attribute)}var timeout=false;if(opts.activation=="hover"){org_elem.hover(function(){active_tiptip()},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}else if(opts.activation=="focus"){org_elem.focus(function(){active_tiptip()}).blur(function(){deactive_tiptip()})}else if(opts.activation=="click"){org_elem.click(function(){active_tiptip();return false}).hover(function(){},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}function active_tiptip(){opts.enter.call(this);tiptip_content.html(org_title);tiptip_holder.hide().removeAttr("class").css("margin","0");tiptip_arrow.removeAttr("style");var top=parseInt(org_elem.offset()['top']);var left=parseInt(org_elem.offset()['left']);var org_width=parseInt(org_elem.outerWidth());var org_height=parseInt(org_elem.outerHeight());var tip_w=tiptip_holder.outerWidth();var tip_h=tiptip_holder.outerHeight();var w_compare=Math.round((org_width-tip_w)/2);var h_compare=Math.round((org_height-tip_h)/2);var marg_left=Math.round(left+w_compare);var marg_top=Math.round(top+org_height+opts.edgeOffset);var t_class="";var arrow_top="";var arrow_left=Math.round(tip_w-12)/2;if(opts.defaultPosition=="bottom"){t_class="_bottom"}else if(opts.defaultPosition=="top"){t_class="_top"}else if(opts.defaultPosition=="left"){t_class="_left"}else if(opts.defaultPosition=="right"){t_class="_right"}var right_compare=(w_compare+left)<parseInt($(window).scrollLeft());var left_compare=(tip_w+left)>parseInt($(window).width());if((right_compare&&w_compare<0)||(t_class=="_right"&&!left_compare)||(t_class=="_left"&&left<(tip_w+opts.edgeOffset+5))){t_class="_right";arrow_top=Math.round(tip_h-13)/2;arrow_left=-12;marg_left=Math.round(left+org_width+opts.edgeOffset);marg_top=Math.round(top+h_compare)}else if((left_compare&&w_compare<0)||(t_class=="_left"&&!right_compare)){t_class="_left";arrow_top=Math.round(tip_h-13)/2;arrow_left=Math.round(tip_w);marg_left=Math.round(left-(tip_w+opts.edgeOffset+5));marg_top=Math.round(top+h_compare)}var top_compare=(top+org_height+opts.edgeOffset+tip_h+8)>parseInt($(window).height()+$(window).scrollTop());var bottom_compare=((top+org_height)-(opts.edgeOffset+tip_h+8))<0;if(top_compare||(t_class=="_bottom"&&top_compare)||(t_class=="_top"&&!bottom_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_top"}else{t_class=t_class+"_top"}arrow_top=tip_h;marg_top=Math.round(top-(tip_h+5+opts.edgeOffset))}else if(bottom_compare|(t_class=="_top"&&bottom_compare)||(t_class=="_bottom"&&!top_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_bottom"}else{t_class=t_class+"_bottom"}arrow_top=-12;marg_top=Math.round(top+org_height+opts.edgeOffset)}if(t_class=="_right_top"||t_class=="_left_top"){marg_top=marg_top+5}else if(t_class=="_right_bottom"||t_class=="_left_bottom"){marg_top=marg_top-5}if(t_class=="_left_top"||t_class=="_left_bottom"){marg_left=marg_left+5}tiptip_arrow.css({"margin-left":arrow_left+"px","margin-top":arrow_top+"px"});tiptip_holder.css({"margin-left":marg_left+"px","margin-top":marg_top+"px"}).attr("class","tip"+t_class);if(timeout){clearTimeout(timeout)}timeout=setTimeout(function(){tiptip_holder.stop(true,true).fadeIn(opts.fadeIn)},opts.delay)}function deactive_tiptip(){opts.exit.call(this);if(timeout){clearTimeout(timeout)}tiptip_holder.fadeOut(opts.fadeOut)}}})}})(jQuery);
872
- jQuery(".tips, .help_tip").tipTip({
873
- 'attribute' : 'data-tip',
874
- 'fadeIn' : 50,
875
- 'fadeOut' : 50,
876
- 'delay' : 200
877
- });
878
- jQuery('input[value="billing_booking_delivery_t"]').parent().parent().hide();
879
- jQuery('.delete-option').live('click',function() {
880
- jQuery(this).parent().remove();
881
- });
882
- jQuery('.button.add_option').live('click',function() {
883
- jQuery(this).before(' <span><br /><input type="text" id="options" value="" name="billing['+jQuery(this).attr('rel')+'][options][option-'+ (jQuery(this).parent().find('input').length + 1) +']"/><span class="delete-option" style="cursor:pointer;border:1px solid">Удалить</span></span>');
884
- });
885
- jQuery('input[type="radio"]').live('click',function() {
886
- if( jQuery(this).val() == 'select' || jQuery(this).val() == 'radio') {
887
- jQuery(this).parent().parent().find('td').css('border-bottom', 'none');
888
- jQuery(this).parent().parent().addClass('parrent_td_option'+jQuery('.button.add_option').length);
889
- if('billing[new_fild][name][]' != jQuery(this).parent().parent().find('td:first input').attr('name') )
890
- jQuery(this).parent().parent().after('<tr style="border-top:0" class="tr_td_option'+jQuery('.button.add_option').length +'" ><td style="border-top:0;padding-left: 72%;" colspan="9"> <span><input id="options" type="text" value="" name="billing['+jQuery(this).parent().parent().find('td:first input').val()+'][options][option-1]"/><span class="delete-option" style="cursor:pointer;border:1px solid">Удалить</span></span> <div class="button add_option" rel="'+jQuery(this).parent().parent().find('td:first input').val()+'">Добавить еще</div></td></tr>');
891
- else jQuery(this).parent().parent().after('<tr style="border-top:0" class="tr_td_option'+jQuery('.button.add_option').length +'" ><td style="border-top:0;padding-left: 72%;" colspan="9"> <span><input id="options" type="text" value="" name="billing[new_fild][options][option-1]"/><span class="delete-option" style="cursor:pointer;border:1px solid">Удалить</span></span> <div class="button add_option" rel="new_fild">Добавить еще</div></td></tr>');
892
- } else {
893
- if(jQuery(this).parent().parent().find('td').attr('style') != '') {
894
- jQuery(this).parent().parent().find('td').attr('style', '');
895
- var text = jQuery(this).parent().parent().attr('class');//parrent_td_option
896
- text = text.replace(/parrent_td_option/g,'');
897
- jQuery('tr.tr_td_option'+text).remove();
898
- jQuery(this).parent().parent().attr('class', '');
899
- }
900
- }
901
- });
902
-
903
- jQuery('input#options').live('blur', function() {
904
- var text = jQuery(this).attr('name');
905
- text = text.replace(/\[options\]\[(.*)\]/g,'[options]['+ jQuery(this).val() +']');
906
- jQuery(this).attr('name', text);
907
- });
908
- jQuery('.button#billing').live('click',function() {
909
- var obj = jQuery(this).parent().parent();
910
- 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><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>');
911
- obj.removeClass('nodrop nodrag');
912
- 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>');
913
- });
914
- jQuery('.button#shipping').live('click',function() {
915
- var obj = jQuery(this).parent().parent();
916
- 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>');
917
- obj.removeClass('nodrop nodrag');
918
- 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>');
919
- });
920
- jQuery('.button#order').live('click',function() {
921
- var obj = jQuery(this).parent().parent();
922
- 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>');
923
- obj.removeClass('nodrop nodrag');
924
- 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>');
925
- });
926
-
927
- jQuery('.button#billing_delete').live('click',function() {
928
- var obj = jQuery(this).parent().parent();
929
- var obj_r = obj.parent();
930
- obj.remove();
931
- obj_r.find("tr").each(function(i, e){
932
- jQuery(e).find("td input#order_count").val(i);
933
- });
934
- });
935
- jQuery(document).ready(function() {
936
- jQuery(".myTable").tableDnD({
937
- onDragClass: "sorthelper",
938
- onDrop: function(table, row) {
939
- var data = new Object();
940
- data.data = new Object();
941
- data.key = jQuery(table).find("tr td input").attr("rel");
942
- jQuery(row).fadeOut("fast").fadeIn("slow");
943
-
944
- jQuery(table).find("tr").each(function(i, e){
945
- var id = jQuery(e).find("td input#order_count").attr("id");
946
- data.data[i] = id;
947
- jQuery(e).find("td input#order_count").val(i);
948
- });
949
- }
950
- });
951
- });
952
- </script>
953
- <?php } ?>
954
-
955
- </div>
956
- <?php
957
- }
958
- function woocommerce_get_customer_meta_fields_saph_ed() {
959
- $show_fields = apply_filters('woocommerce_customer_meta_fields', array(
960
- 'billing' => array(
961
- 'title' => __('Customer Billing Address', 'woocommerce'),
962
- 'fields' => array(
963
- 'billing_first_name' => array(
964
- 'label' => __('First name', 'woocommerce'),
965
- 'description' => ''
966
- ),
967
- 'billing_last_name' => array(
968
- 'label' => __('Last name', 'woocommerce'),
969
- 'description' => ''
970
- ),
971
- 'billing_company' => array(
972
- 'label' => __('Company', 'woocommerce'),
973
- 'description' => ''
974
- ),
975
- 'billing_address_1' => array(
976
- 'label' => __('Address 1', 'woocommerce'),
977
- 'description' => ''
978
- ),
979
- 'billing_address_2' => array(
980
- 'label' => __('Address 2', 'woocommerce'),
981
- 'description' => ''
982
- ),
983
- 'billing_city' => array(
984
- 'label' => __('City', 'woocommerce'),
985
- 'description' => ''
986
- ),
987
- 'billing_postcode' => array(
988
- 'label' => __('Postcode', 'woocommerce'),
989
- 'description' => ''
990
- ),
991
- 'billing_state' => array(
992
- 'label' => __('State/County', 'woocommerce'),
993
- 'description' => __('Country or state code', 'woocommerce'),
994
- ),
995
- 'billing_country' => array(
996
- 'label' => __('Country', 'woocommerce'),
997
- 'description' => __('2 letter Country code', 'woocommerce'),
998
- ),
999
- 'billing_phone' => array(
1000
- 'label' => __('Telephone', 'woocommerce'),
1001
- 'description' => ''
1002
- ),
1003
- 'billing_email' => array(
1004
- 'label' => __('Email', 'woocommerce'),
1005
- 'description' => ''
1006
- )
1007
- )
1008
- ),
1009
- 'shipping' => array(
1010
- 'title' => __('Customer Shipping Address', 'woocommerce'),
1011
- 'fields' => array(
1012
- 'shipping_first_name' => array(
1013
- 'label' => __('First name', 'woocommerce'),
1014
- 'description' => ''
1015
- ),
1016
- 'shipping_last_name' => array(
1017
- 'label' => __('Last name', 'woocommerce'),
1018
- 'description' => ''
1019
- ),
1020
- 'shipping_company' => array(
1021
- 'label' => __('Company', 'woocommerce'),
1022
- 'description' => ''
1023
- ),
1024
- 'shipping_address_1' => array(
1025
- 'label' => __('Address 1', 'woocommerce'),
1026
- 'description' => ''
1027
- ),
1028
- 'shipping_address_2' => array(
1029
- 'label' => __('Address 2', 'woocommerce'),
1030
- 'description' => ''
1031
- ),
1032
- 'shipping_city' => array(
1033
- 'label' => __('City', 'woocommerce'),
1034
- 'description' => ''
1035
- ),
1036
- 'shipping_postcode' => array(
1037
- 'label' => __('Postcode', 'woocommerce'),
1038
- 'description' => ''
1039
- ),
1040
- 'shipping_state' => array(
1041
- 'label' => __('State/County', 'woocommerce'),
1042
- 'description' => __('State/County or state code', 'woocommerce')
1043
- ),
1044
- 'shipping_country' => array(
1045
- 'label' => __('Country', 'woocommerce'),
1046
- 'description' => __('2 letter Country code', 'woocommerce')
1047
- )
1048
- )
1049
- )
1050
- ));
1051
- return $show_fields;
1052
- }
1053
- function woocommerce_get_customer_meta_fields_saphali() {
1054
- $fieldss = get_option('woocommerce_saphali_filds_filters');
1055
-
1056
- $show_fields = $this->woocommerce_get_customer_meta_fields_saph_ed();
1057
-
1058
-
1059
-
1060
- if(is_array($fieldss)) {
1061
- if(is_array($fieldss["billing"])) {
1062
- $billing = array();
1063
- foreach($fieldss["billing"] as $key => $value) {
1064
- if(isset($show_fields["billing"]['fields'][$key])) continue;
1065
-
1066
- foreach($value as $k_post=> $v_post){
1067
- if( 'on' == $v_post ) {
1068
- $value[$k_post] = true;
1069
- } elseif(in_array($k_post, array('public','clear','required'))) { $value[$k_post] = false; }
1070
- }
1071
- $billing = array_merge( $billing , array ($key => $value));
1072
- }
1073
- }
1074
- if(is_array($fieldss["shipping"])) {
1075
- $shipping = array();
1076
- foreach($fieldss["shipping"] as $key => $value) {
1077
- if(isset($show_fields["shipping"]['fields'][$key])) continue;
1078
- foreach($value as $k_post=> $v_post){
1079
- if( 'on' == $v_post ) {
1080
- $value[$k_post] = true;
1081
- } elseif(in_array($k_post, array('public','clear','required'))) { $value[$k_post] = false; }
1082
- }
1083
- $shipping = array_merge( $shipping , array ($key => $value));
1084
- }
1085
- }
1086
- if(is_array($fieldss["order"])) {
1087
- $orders = array();
1088
- foreach($fieldss["order"] as $key => $value) {
1089
- if(isset($show_fields["order"]['fields'][$key])) continue;
1090
- foreach($value as $k_post=> $v_post){
1091
- if( 'on' == $v_post ) {
1092
- $value[$k_post] = true;
1093
- } elseif(in_array($k_post, array('public','clear','required'))) { $value[$k_post] = false; }
1094
- }
1095
- $orders = array_merge( $orders , array ($key => $value));
1096
- }
1097
- }
1098
- }
1099
-
1100
- if(!isset($show_fields['billing']['title'])) {
1101
- $_show_fields['billing']['title'] = $show_fields['billing']['title'];
1102
- }
1103
-
1104
- if(isset($billing))
1105
- $_show_fields['billing'] = $billing;
1106
-
1107
- if(!isset($show_fields['shipping']['title'])) {
1108
- $_show_fields['shipping']['title'] = $show_fields['shipping']['title'];
1109
- }
1110
-
1111
- if(isset($shipping))
1112
- $_show_fields['shipping'] = $shipping;
1113
-
1114
-
1115
- if(isset($show_fields['order']) && !(@is_array($show_fields['order']['fields']))) {
1116
- $_show_fields['order']['title'] = 'Дополнительные поля';
1117
- }
1118
- if(isset($orders))
1119
- $_show_fields['order'] = $orders;
1120
- if (isset($_show_fields)) {
1121
- return $_show_fields;
1122
- }
1123
-
1124
- }
1125
- function woocommerce_save_customer_meta_fields_saphali( $user_id ) {
1126
- if ( ! current_user_can( 'manage_woocommerce' ) )
1127
- return $columns;
1128
-
1129
- $show_fields = $this->woocommerce_get_customer_meta_fields_saphali();
1130
- if(!empty($show_fields["billing"])) {
1131
- $save_fields["billing"]['title'] = __('Customer Billing Address', 'woocommerce');
1132
- $save_fields["billing"]['fields'] = $show_fields["billing"];
1133
- }
1134
- if(!empty($show_fields["shipping"])) {
1135
- $save_fields["shipping"]['title'] = __('Customer Shipping Address', 'woocommerce');
1136
- $save_fields["shipping"]['fields'] = $show_fields["shipping"];
1137
- }
1138
- /* if(!empty($show_fields["order"])) {
1139
- $save_fields["order"]['title'] = __('Дополнительные поля', 'woocommerce');
1140
- $save_fields["order"]['fields'] = $show_fields["order"];
1141
- } */
1142
- if(isset($save_fields) && is_array($save_fields))
1143
- foreach( $save_fields as $fieldset )
1144
- foreach( $fieldset['fields'] as $key => $field )
1145
- if ( isset( $_POST[ $key ] ) )
1146
- update_user_meta( $user_id, $key, trim( esc_attr( $_POST[ $key ] ) ) );
1147
- }
1148
- function woocommerce_admin_order_data_after_billing_address_s($order) {
1149
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1150
-
1151
- echo '<div class="address">';
1152
- if(is_array($billing_data["billing"])) {
1153
- foreach ( $billing_data["billing"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1154
-
1155
- $field_name = '_'.$key;
1156
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1157
- $value_fild = @$order->order_custom_fields[$field_name][0];
1158
- else
1159
- $value_fild = $order->__get( $key );
1160
- if ( $value_fild && !empty($field['label']) ) echo '<p><strong>'.$field['label'].':</strong> '.$value_fild.'</p>';
1161
-
1162
- endforeach;
1163
- }
1164
- echo '</div>';
1165
- }
1166
- function woocommerce_admin_order_data_after_shipping_address_s($order) {
1167
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1168
- echo '<div class="address">';
1169
- if(is_array($billing_data["shipping"])) {
1170
- foreach ( $billing_data["shipping"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1171
-
1172
- $field_name = '_'.$key;
1173
-
1174
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1175
- $value_fild = @$order->order_custom_fields[$field_name][0];
1176
- else
1177
- $value_fild = $order->__get( $key );
1178
- if ( $value_fild && !empty($field['label']) ) echo '<p><strong>'.$field['label'].':</strong> '.$value_fild.'</p>';
1179
-
1180
- endforeach;
1181
- }
1182
- echo '</div>';
1183
- }
1184
- function woocommerce_admin_order_data_after_order_details_s($order) {
1185
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1186
- echo '<div class="address">';
1187
- if(is_array($billing_data["order"])) {
1188
- foreach ( $billing_data["order"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1189
-
1190
- $field_name = '_'.$key;
1191
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1192
- $value_fild = @$order->order_custom_fields[$field_name][0];
1193
- else
1194
- $value_fild = $order->__get( $key );
1195
- if ( $value_fild && !empty($field['label']) )
1196
-
1197
- echo '<div class="form-field form-field-wide"><label>'. $field['label']. ':</label> ' . $value_fild.'</div>';
1198
-
1199
- endforeach;
1200
- }
1201
- echo '</div>';
1202
-
1203
- }
1204
- function saphali_custom_override_checkout_fields( $fields ) {
1205
-
1206
- $fieldss = get_option('woocommerce_saphali_filds_filters');
1207
- if(is_array($fieldss)) {
1208
- $fields["billing"] = $fieldss["billing"];
1209
- $fields["shipping"] = $fieldss["shipping"];
1210
- $fields["order"] = $fieldss["order"];
1211
- }
1212
- foreach(array("billing", "shipping", "order") as $v)
1213
- foreach($fields[$v] as $key => $value) {
1214
- if(isset($fields[$v][$key]["label"]))
1215
- $fields[$v][$key]["label"] = __($value["label"], 'woocommerce');
1216
- if(isset($fields[$v][$key]["placeholder"]))
1217
- $fields[$v][$key]["placeholder"] = __($value["placeholder"], 'saphali-woocommerce-lite');
1218
- }
1219
- return $fields;
1220
- }
1221
- function saphali_custom_edit_address_fields( $fields ) {
1222
- global $wp;
1223
- $fieldss = get_option('woocommerce_saphali_filds_filters');
1224
- if(is_array($fieldss))
1225
- $_fields = $fieldss["billing"];
1226
- if( isset($_fields) && is_array($_fields) )
1227
- foreach($_fields as $key => $value) {
1228
- if(str_replace( 'billing_','', $key ) != 'email')
1229
- $__fields[wc_edit_address_i18n( sanitize_key( $wp->query_vars['edit-address'] ), true ) . '_' . str_replace( 'billing_','', $key ) ] = $value;
1230
- }
1231
- $_a_ = array_diff($__fields, $fields);
1232
- if(is_array($_a_) && is_array($fields) ) $fields = (array)$fields + (array)$_a_;
1233
-
1234
- foreach($fields as $key => $value) {
1235
- if(isset($fields[$key]["label"]))
1236
- $fields[$key]["label"] = __($value["label"], 'woocommerce');
1237
- if(isset($fields[$key]["placeholder"]))
1238
- $fields[$key]["placeholder"] = __($value["placeholder"], 'woocommerce');
1239
- }
1240
- return $fields;
1241
- }
1242
- function saphali_custom_billing_fields( $fields ) {
1243
-
1244
- $fieldss = get_option('woocommerce_saphali_filds_filters');
1245
- if(is_array($fieldss))
1246
- $fields = $fieldss["billing"];
1247
- foreach($fields as $key => $value) {
1248
- if(isset($fields[$key]["label"]))
1249
- $fields[$key]["label"] = __($value["label"], 'woocommerce');
1250
- if(isset($fields[$key]["placeholder"]))
1251
- $fields[$key]["placeholder"] = __($value["placeholder"], 'woocommerce');
1252
-
1253
- }
1254
- return $fields;
1255
- }
1256
- function saphali_custom_shipping_fields( $fields ) {
1257
- $fieldss = get_option('woocommerce_saphali_filds_filters');
1258
- if(is_array($fieldss))
1259
- $fields = $fieldss["shipping"];
1260
- foreach($fields as $key => $value) {
1261
- if(isset($fields[$key]["label"]))
1262
- $fields[$key]["label"] = __($value["label"], 'woocommerce');
1263
- if(isset($fields[$key]["placeholder"]))
1264
- $fields[$key]["placeholder"] = __($value["placeholder"], 'woocommerce');
1265
- }
1266
- return $fields;
1267
- }
1268
- public function store_order_id( $arg ) {
1269
- if ( is_int( $arg ) ) $this->email_order_id = $arg;
1270
- elseif ( is_array( $arg ) && array_key_exists( 'order_id', $arg ) ) $this->email_order_id = $arg['order_id'];
1271
- }
1272
- public function email_pickup_location( $template_name, $template_path, $located ) {
1273
- global $_shipping_data, $_billing_data;
1274
- if ( $template_name == 'emails/email-addresses.php' && $this->email_order_id ) {
1275
-
1276
- $order = new WC_Order( $this->email_order_id );
1277
-
1278
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1279
- echo '<div class="address">';
1280
-
1281
- if(is_array($billing_data["billing"]) && !$_billing_data) {
1282
- foreach ( $billing_data["billing"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1283
- $field_name = '_'.$key;
1284
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1285
- $value_fild = @$order->order_custom_fields[$field_name][0];
1286
- else
1287
- $value_fild = $order->__get( $key );
1288
- if ( $value_fild && !empty($field['label']) )
1289
- echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1290
- endforeach;
1291
- }
1292
- if(is_array($billing_data["shipping"]) && !$_shipping_data) {
1293
- foreach ( $billing_data["shipping"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1294
- $field_name = '_'.$key;
1295
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1296
- $value_fild = @$order->order_custom_fields[$field_name][0];
1297
- else
1298
- $value_fild = $order->__get( $key );
1299
- if ( $value_fild && !empty($field['label']))
1300
- echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1301
- endforeach;
1302
- }
1303
- if(is_array($billing_data["order"])) {
1304
- foreach ( $billing_data["order"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1305
-
1306
- $field_name = '_'.$key;
1307
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1308
- $value_fild = @$order->order_custom_fields[$field_name][0];
1309
- else
1310
- $value_fild = $order->__get( $key );
1311
- if ( $value_fild && !empty($field['label']) )
1312
-
1313
- echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1314
-
1315
- endforeach;
1316
- }
1317
- echo '</div>';
1318
- }
1319
- }
1320
- /* function formatted_billing_address($address, $order) {
1321
- global $billing_data, $_billing_data;
1322
- if( empty($billing_data) )
1323
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1324
- if(is_array($billing_data["billing"])) {
1325
- $_billing_data = true;
1326
- $no_fild = array ('_billing_booking_delivery_t', '_billing_booking_delivery');
1327
- foreach ( $billing_data["billing"] as $key => $field ) : if (isset($field['show']) && !$field['show'] ) continue;
1328
-
1329
- $field_name = '_'.$key;
1330
-
1331
- if(in_array($field_name, $no_fild)) continue;
1332
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1333
- $value_fild = @$order->order_custom_fields[$field_name][0];
1334
- else
1335
- $value_fild = $order->__get( $key );
1336
- if ( $value_fild && !empty($field['label']))
1337
- echo '<label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'<br />';
1338
- endforeach;
1339
- }
1340
- return $address;
1341
- }
1342
- function formatted_shipping_address($address, $order) {
1343
- global $billing_data, $_shipping_data;
1344
- if( empty($billing_data) )
1345
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1346
- if(is_array($billing_data["shipping"])) {
1347
- $_shipping_data = true;
1348
- foreach ( $billing_data["shipping"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1349
- $field_name = '_'.$key;
1350
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1351
- $value_fild = @$order->order_custom_fields[$field_name][0];
1352
- else
1353
- $value_fild = $order->__get( $key );
1354
- if ( $value_fild && !empty($field['label'])) {
1355
- echo '<label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'<br />';
1356
- $address[$key] = $value_fild;
1357
- }
1358
- endforeach;
1359
- }
1360
- return $address;
1361
- }*/
1362
- function order_pickup_location($order_id) {
1363
- global $_billing_data, $_shipping_data;
1364
- $order = new WC_Order( $order_id );
1365
-
1366
- if ( is_object($order) ) {
1367
-
1368
- $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1369
-
1370
- echo '<div class="address">';
1371
-
1372
- if(is_array($billing_data["billing"]) && !$_billing_data) {
1373
- foreach ( $billing_data["billing"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1374
- $field_name = '_'.$key;
1375
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1376
- $value_fild = @$order->order_custom_fields[$field_name][0];
1377
- else
1378
- $value_fild = $order->__get( $key );
1379
- if ( $value_fild && !empty($field['label']))
1380
- echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1381
- endforeach;
1382
- }
1383
- if(is_array($billing_data["shipping"]) && !$_shipping_data) {
1384
- foreach ( $billing_data["shipping"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1385
- $field_name = '_'.$key;
1386
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1387
- $value_fild = @$order->order_custom_fields[$field_name][0];
1388
- else
1389
- $value_fild = $order->__get( $key );
1390
- if ( $value_fild && !empty($field['label']) )
1391
- echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1392
- endforeach;
1393
- }
1394
- if(is_array($billing_data["order"]) ) {
1395
- foreach ( $billing_data["order"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1396
- $field_name = '_'.$key;
1397
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1398
- $value_fild = @$order->order_custom_fields[$field_name][0];
1399
- else
1400
- $value_fild = $order->__get( $key );
1401
- if ( $value_fild && !empty($field['label']) )
1402
- echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1403
- endforeach;
1404
- }
1405
- echo '</div>';
1406
- }
1407
- }
1408
- function print_columns ($columns) {
1409
- return $this->column_count_saphali;
1410
- }
1411
- function related_print_columns ($columns) {
1412
- if( isset($columns['columns']) ) {
1413
- $columns['columns'] = $this->column_count_saphali;
1414
- $columns['posts_per_page'] = $this->column_count_saphali;
1415
- }
1416
-
1417
- return $columns;
1418
- }
1419
- function print_script_columns($woocommerce_loop) {
1420
- global $woocommerce_loop;
1421
- if($woocommerce_loop['columns'] > 0 && $woocommerce_loop['columns'] != 4) {
1422
- ?>
1423
- <style type='text/css'>
1424
- .woocommerce ul.products li.product {
1425
- width:<?php if($woocommerce_loop['columns'] <= 3 ) echo floor(100/$woocommerce_loop['columns'] - $woocommerce_loop['columns']); elseif($woocommerce_loop['columns'] > 3 )echo floor(100/$woocommerce_loop['columns'] - 4);?>%;
1426
- }
1427
- </style>
1428
- <?php
1429
- }
1430
- }
1431
- }
1432
-
1433
- add_action('plugins_loaded', 'woocommerce_lang_s_l', 0);
1434
- if ( ! function_exists( 'woocommerce_lang_s_l' ) ) {
1435
- function woocommerce_lang_s_l() {
1436
- $lite = new saphali_lite();
1437
- if( is_admin() )
1438
- add_action( 'admin_enqueue_scripts', array( $lite, 'admin_enqueue_scripts_page_saphali' ) );
1439
- }
1440
- }
1441
- //END
1442
- add_action("wp_head", '_print_script_columns', 10 );
1443
- add_action("admin_head", '_print_script_columns', 10);
1444
- function _print_script_columns() {
1445
- if(apply_filters( 'woocommerce_currency', get_option('woocommerce_currency') ) != 'RUB' || !(version_compare( WOOCOMMERCE_VERSION, '2.5.2', '<' ) || SAPHALI_LITE_SYMBOL ) ) return;
1446
- ?>
1447
- <style type="text/css">
1448
- /* @font-face { font-family: "Rubl Sign"; src: url(<?php echo SAPHALI_PLUGIN_DIR_URL; ?>ruble.eot); } */
1449
-
1450
- @font-face { font-family: "rub-arial-regular"; src: url("<?php echo SAPHALI_PLUGIN_DIR_URL; ?>ruble-simb.woff"), url("<?php echo SAPHALI_PLUGIN_DIR_URL; ?>ruble-simb.ttf");
1451
- }
1452
- span.rur {
1453
- font-family: rub-arial-regular;
1454
- text-transform: uppercase;
1455
- }
1456
- span.rur span { display: none; }
1457
-
1458
- /* span.rur { font-family: "Rubl Sign"; text-transform: uppercase;}
1459
- span.rur:before {top: 0.06em;left: 0.55em;content: '\2013'; position: relative;} */
1460
- </style>
1461
- <?php
1462
- }
1463
-
1464
-
1465
- register_activation_hook( __FILE__, 'saphali_woo_lite_install' );
1466
-
1467
- function saphali_woo_lite_install() {
1468
- $filds_finish_filter = get_option('woocommerce_saphali_filds_filters');
1469
- if($filds_finish_filter) {
1470
- foreach($filds_finish_filter['billing'] as $k_f => $v_f) {
1471
- $new_key = str_replace('billing_', '' , $k_f);
1472
- if(in_array($new_key, array('country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ) )) {
1473
- $locate[$new_key] = $v_f;
1474
- if( isset($locate[$new_key]['clear']) && $locate[$new_key]['clear'] == 'on') $locate[$new_key]['clear'] = true;
1475
- if( isset($locate[$new_key]['required']) && $locate[$new_key]['required'] == 'on') $locate[$new_key]['required'] = true;
1476
- } elseif(in_array(str_replace('shipping_', '' , $k_f), array('country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ) )) {
1477
- $locate[$new_key] = $filds_finish_filter['shipping'][$k_f];
1478
- if( isset($locate[$new_key]['clear']) && $locate[$new_key]['clear'] == 'on') $locate[$new_key]['clear'] = true;
1479
- if( isset($locate[$new_key]['required']) && $locate[$new_key]['required'] == 'on') $locate[$new_key]['required'] = true;
1480
- }
1481
-
1482
- }
1483
- update_option('woocommerce_saphali_filds_locate',$locate);
1484
- }
1485
- //if(!update_option('woocommerce_informal_localisation_type' , 'yes'))add_option('woocommerce_informal_localisation_type' , 'yes');
1486
- //global $woocommerce;
1487
- //copy( SAPHALI_PLUGIN_DIR_PATH . '/languages/woocommerce-ru_RU.mo', $woocommerce->plugin_path() .'/i18n/languages/informal/woocommerce-ru_RU.mo');
1488
- //copy( SAPHALI_PLUGIN_DIR_PATH . '/languages/woocommerce-ru_RU.po', $woocommerce->plugin_path() .'/i18n/languages/informal/woocommerce-ru_RU.po');
 
 
 
 
 
 
 
 
 
 
 
 
 
1489
  }
1
+ <?php
2
+ /*
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.6.6
7
+ Author: Saphali
8
+ Author URI: http://saphali.com/
9
+ Text Domain: saphali-woocommerce-lite
10
+ Domain Path: /languages
11
+
12
+ */
13
+
14
+
15
+ /*
16
+
17
+ This program is free software; you can redistribute it and/or modify
18
+ it under the terms of the GNU General Public License, version 2, as
19
+ published by the Free Software Foundation.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program; if not, write to the Free Software
28
+
29
+ */
30
+
31
+ /* Add a custom payment class to woocommerce
32
+ ------------------------------------------------------------ */
33
+ define('SAPHALI_LITE_SYMBOL', 1 );
34
+
35
+ // Подключение валюты и локализации
36
+ define('SAPHALI_PLUGIN_DIR_URL',plugin_dir_url(__FILE__));
37
+ define('SAPHALI_LITE_VERSION', '1.6.6' );
38
+ define('SAPHALI_PLUGIN_DIR_PATH',plugin_dir_path(__FILE__));
39
+ class saphali_lite {
40
+ var $email_order_id;
41
+ var $column_count_saphali;
42
+ function __construct() {
43
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.2.0', '<' ) || version_compare( WOOCOMMERCE_VERSION, '2.5.0', '>' ) )
44
+ add_action('before_woocommerce_init', array($this,'load_plugin_textdomain'), 9);
45
+ else
46
+ add_action('before_woocommerce_init', array($this,'load_plugin_textdomain_th'), 9);
47
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) ) add_action('admin_menu', array($this,'woocommerce_saphali_admin_menu_s_l'), 9);
48
+ else add_action('admin_menu', array($this,'woocommerce_saphali_admin_menu_s_l'), 10);
49
+
50
+ add_action( 'woocommerce_thankyou', array( $this, 'order_pickup_location' ), 20 );
51
+ add_action( 'woocommerce_view_order', array( $this, 'order_pickup_location' ), 20 );
52
+
53
+ add_action( 'woocommerce_after_template_part', array( $this, 'email_pickup_location' ), 10, 3 );
54
+
55
+ // add_action( 'woocommerce_admin_order_totals_after_shipping', array( $this, 'woocommerce_admin_order_totals_after_shipping' ), 1 );
56
+ add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'store_order_id' ), 1 );
57
+ add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'store_order_id' ), 1 );
58
+ add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'store_order_id' ), 1 );
59
+ add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'store_order_id' ), 1 );
60
+ add_action( 'woocommerce_order_status_failed_to_completed_notification', array( $this, 'store_order_id' ), 1 );
61
+ add_action( 'woocommerce_order_status_completed_notification', array( $this, 'store_order_id' ), 1 );
62
+ add_action( 'woocommerce_new_customer_note_notification', array( $this, 'store_order_id' ), 1 );
63
+ add_action( 'wp_head', array( $this, 'generator' ) );
64
+ add_filter( 'woocommerce_order_formatted_billing_address', array($this,'formatted_billing_address') , 10 , 2);
65
+ add_filter( 'woocommerce_order_formatted_shipping_address', array($this,'formatted_shipping_address') , 10 , 2);
66
+
67
+ if(@$_GET['page'] != 'woocommerce_saphali_s_l' && @$_GET['tab'] !=1 ) {
68
+ // Hook in
69
+ add_filter( 'woocommerce_checkout_fields' , array($this,'saphali_custom_override_checkout_fields') );
70
+ add_filter( 'wp' , array($this,'wp') );
71
+
72
+ add_filter( 'woocommerce_billing_fields', array($this,'saphali_custom_billing_fields'), 10, 1 );
73
+ add_filter( 'woocommerce_shipping_fields', array($this,'saphali_custom_shipping_fields'), 10, 1 );
74
+ add_filter( 'woocommerce_default_address_fields', array($this,'woocommerce_default_address_fields'), 10, 1 );
75
+ //add_filter( 'woocommerce_get_country_locale', array($this,'woocommerce_get_country_locale'), 10, 1 );
76
+ add_action('admin_init', array($this,'woocommerce_customer_meta_fields_action'), 20);
77
+ add_action( 'personal_options_update', array($this,'woocommerce_save_customer_meta_fields_saphali') );
78
+ add_action( 'edit_user_profile_update', array($this,'woocommerce_save_customer_meta_fields_saphali') );
79
+ /* add_action( 'woocommerce_admin_order_data_after_billing_address', array($this,'woocommerce_admin_order_data_after_billing_address_s') );
80
+ add_action( 'woocommerce_admin_order_data_after_shipping_address', array($this,'woocommerce_admin_order_data_after_shipping_address_s') ); */
81
+ add_action( 'woocommerce_admin_order_data_after_order_details', array($this,'woocommerce_admin_order_data_after_order_details_s') );
82
+
83
+ }
84
+ add_filter( 'woocommerce_currencies', array($this,'add_inr_currency') , 11);
85
+ add_filter( 'woocommerce_currency_symbol', array($this,'add_inr_currency_symbol') , 1, 2 );
86
+ add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'checkout_update_order_meta' ), 99, 2 );
87
+ $this->column_count_saphali = get_option('column_count_saphali');
88
+ if(!empty($this->column_count_saphali)) {
89
+ global $woocommerce_loop;
90
+ $woocommerce_loop['columns'] = $this->column_count_saphali;
91
+ add_action("wp_head", array($this,'print_script_columns'), 10, 1);
92
+ add_filter("loop_shop_columns", array($this, 'print_columns'), 10, 1);
93
+ add_filter("woocommerce_output_related_products_args", array($this, 'related_print_columns'), 10, 1);
94
+ }
95
+ if(is_admin()) {
96
+ add_filter( 'woocommerce_admin_billing_fields', array($this,'woocommerce_admin_billing_fields'), 10, 1 );
97
+ add_filter( 'woocommerce_admin_shipping_fields', array($this,'woocommerce_admin_shipping_fields'), 10, 1 );
98
+ }
99
+ }
100
+ function formatted_billing_address($address, $order) {
101
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
102
+ foreach ( array("billing") as $type )
103
+ {
104
+ if ( isset($billing_data[$type]) && is_array($billing_data[$type]))
105
+ {
106
+ foreach ( $billing_data[$type] as $key => $field ) {
107
+
108
+ if (isset($field['public']) && $field['public'] ) {
109
+ $address[str_replace($type . '_', '', $key)] = get_post_meta( $order->id, '_' . $key, true );
110
+ if( !empty($address[str_replace($type . '_', '', $key)]) && ( strpos($key, 'new_fild') !== false) )
111
+ echo '<label><strong>'. $field['label']. ':</strong></label> ' . $address[str_replace($type . '_', '', $key)].'<br />';
112
+ }
113
+ }
114
+ }
115
+ }
116
+ return($address);
117
+ }
118
+ function formatted_shipping_address($address, $order) {
119
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
120
+ if(is_array($billing_data["order"])) {
121
+ foreach ( $billing_data["order"] as $key => $field ) {
122
+ if (isset($field['show']) && !$field['show'] || $key == 'order_comments') continue;
123
+ $address[ str_replace('order_', '', $key) ] = get_post_meta( $order->id, '_' . $key, true );
124
+ if( !empty($address[ str_replace('order_', '', $key) ]) && ( strpos($key, 'new_fild') === false) )
125
+ echo '<label><strong>'. $field['label']. ':</strong></label> ' . $address[ str_replace('order_', '', $key) ] . '<br />';
126
+ }
127
+ }
128
+ foreach ( array( "shipping") as $type )
129
+ {
130
+ if ( isset($billing_data[$type]) && is_array($billing_data[$type]))
131
+ {
132
+ foreach ( $billing_data[$type] as $key => $field ) {
133
+
134
+ if (isset($field['public']) && $field['public'] ) {
135
+ $address[str_replace($type . '_', '', $key)] = get_post_meta( $order->id, '_' . $key, true );
136
+ if( !empty($address[str_replace($type . '_', '', $key)]) && ( strpos($key, 'new_fild') === false) ) {
137
+ echo '<label><strong>'. $field['label']. ':</strong></label> ' . $address[str_replace($type . '_', '', $key)].'<br />'; }
138
+
139
+ }
140
+ }
141
+ }
142
+ }
143
+ return($address);
144
+ }
145
+ function woocommerce_admin_billing_fields($billing_fields) {
146
+ if ( !version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) ) {
147
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
148
+ if(is_array($billing_data["billing"])) {
149
+ foreach ( $billing_data["billing"] as $key => $field ) {
150
+ $key = str_replace('billing_', '', $key);
151
+ if (isset($field['show']) && !$field['show'] || $key == 'order_comments') continue;
152
+ if( strpos($key, 'new_fild') === false)
153
+ $billing_fields[$key] = array(
154
+ 'label' => $field['label'],
155
+ 'show' => false
156
+ );
157
+ else
158
+ $billing_fields[$key] = array(
159
+ 'label' => $field['label'],
160
+ 'show' => true
161
+ );
162
+ }
163
+ }
164
+ }
165
+ return $billing_fields;
166
+ }
167
+ function woocommerce_admin_shipping_fields($shipping_fields) {
168
+ if ( !version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) ) {
169
+ $shipping_data = $this->woocommerce_get_customer_meta_fields_saphali();
170
+ if(is_array($shipping_data["shipping"])) {
171
+ foreach ( $shipping_data["shipping"] as $key => $field ) {
172
+ $key = str_replace('shipping_', '', $key);
173
+ if (isset($field['show']) && !$field['show'] || $key == 'order_comments') continue;
174
+ if( strpos($key, 'new_fild') === false)
175
+ $shipping_fields[$key] = array(
176
+ 'label' => $field['label'],
177
+ 'show' => false
178
+ );
179
+ else
180
+ $shipping_fields[$key] = array(
181
+ 'label' => $field['label'],
182
+ 'show' => true
183
+ );
184
+ }
185
+ }
186
+ }
187
+ return $shipping_fields;
188
+ }
189
+
190
+ public function wp( ) {
191
+ if(function_exists('wc_edit_address_i18n')){
192
+ global $wp;
193
+ if(isset($wp->query_vars['edit-address']))
194
+ add_filter( 'woocommerce_'.wc_edit_address_i18n( sanitize_key( $wp->query_vars['edit-address'] ), true ) .'_fields', array($this,'saphali_custom_edit_address_fields'), 10, 1 );
195
+ }
196
+ }
197
+ public function checkout_update_order_meta( $order_id, $posted ) {
198
+ if ( !version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) ) {
199
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
200
+ if(is_array($billing_data["order"])) {
201
+ foreach ( $billing_data["order"] as $key => $field ) {
202
+ if (isset($field['show']) && !$field['show'] || $key == 'order_comments') continue;
203
+ if(!empty($_POST[$key]))
204
+ update_post_meta( $order_id, '_' . $key, $_POST[$key] );
205
+ }
206
+ }
207
+ foreach ( array("billing", "shipping") as $type )
208
+ {
209
+ if ( isset($billing_data[$type]) && is_array($billing_data[$type]))
210
+ {
211
+ foreach ( $billing_data[$type] as $key => $field ) {
212
+
213
+ if (isset($field['public']) && $field['public'] && !empty($_POST[$key])) {
214
+ update_post_meta( $order_id, '_' . $key, $_POST[$key] );
215
+ }
216
+ }
217
+ }
218
+ }
219
+ }
220
+ }
221
+ public function woocommerce_admin_order_totals_after_shipping($id) {
222
+ if( apply_filters( 'woocommerce_currency', get_option('woocommerce_currency') ) == 'RUB' ) {
223
+ ?>
224
+ <script type="text/javascript">
225
+ jQuery( function($){
226
+ $('#woocommerce-order-totals').on( 'change', '#_order_tax, #_order_shipping_tax, #_cart_discount, #_order_discount', function() {
227
+
228
+ var $this = $(this);
229
+ var fields = $this.closest('.totals').find('input');
230
+ var total = 0;
231
+
232
+ fields.each(function(){
233
+ if ( $(this).val() )
234
+ total = total + parseFloat( $(this).val() );
235
+ });
236
+
237
+ var formatted_total = accounting.formatMoney( total, {
238
+ symbol : woocommerce_writepanel_params.currency_format_symbol,
239
+ decimal : woocommerce_writepanel_params.currency_format_decimal_sep,
240
+ thousand : woocommerce_writepanel_params.currency_format_thousand_sep,
241
+ precision : woocommerce_writepanel_params.currency_format_num_decimals,
242
+ format : woocommerce_writepanel_params.currency_format
243
+ } );
244
+ $this.closest('.totals_group').find('span.inline_total').html( formatted_total );
245
+
246
+ } );
247
+ setTimeout(function() {$('span.inline_total').closest('.totals_group').find('input').change();}, 100);
248
+ });
249
+ </script>
250
+ <?php
251
+ }
252
+ }
253
+ public function load_plugin_textdomain() {
254
+ load_plugin_textdomain( 'woocommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
255
+ load_plugin_textdomain( 'saphali-woocommerce-lite', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
256
+ }
257
+ public function load_plugin_textdomain_th() {
258
+ load_plugin_textdomain( 'saphali-woocommerce-lite', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
259
+ }
260
+ public function woocommerce_default_address_fields($locale) {
261
+ $fieldss = get_option('woocommerce_saphali_filds_locate');
262
+ if(is_array($fieldss))
263
+ $locale = $fieldss;
264
+ return $locale;
265
+ }
266
+ public function woocommerce_get_country_locale($locale) {
267
+
268
+ return $locale;
269
+ }
270
+ public function generator() {
271
+ echo "\n\n" . '<!-- Saphali Lite Version -->' . "\n" . '<meta name="generator" content="Saphali Lite ' . esc_attr( SAPHALI_LITE_VERSION ) . '" />' . "\n\n";
272
+ }
273
+ function woocommerce_customer_meta_fields_action() {
274
+ add_action( 'show_user_profile', array($this,'woocommerce_customer_meta_fields_s') );
275
+ add_action( 'edit_user_profile', array($this,'woocommerce_customer_meta_fields_s') );
276
+ }
277
+ function woocommerce_customer_meta_fields_s( $user ) {
278
+ if ( ! current_user_can( 'manage_woocommerce' ) )
279
+ return;
280
+
281
+ $show_fields = $this->woocommerce_get_customer_meta_fields_saphali();
282
+ if(!empty($show_fields["billing"])) {
283
+ $show_field["billing"]['title'] = __('Customer Billing Address', 'woocommerce');
284
+ $show_field["billing"]['fields'] = $show_fields["billing"];
285
+ }
286
+ if(!empty($show_fields["shipping"])) {
287
+ $show_field["shipping"]['title'] = __('Customer Shipping Address', 'woocommerce');
288
+ $show_field["shipping"]['fields'] = $show_fields["shipping"];
289
+ }
290
+ if(is_array($show_field)) {
291
+ $count = 0; echo '<fieldset>';
292
+ foreach( $show_field as $fieldset ) :
293
+ if(!$count) echo '<h2>Дополнительные поля</h2>';
294
+ $count++;
295
+ ?>
296
+ <h3><?php echo $fieldset['title']; ?></h3>
297
+ <table class="form-table">
298
+ <?php
299
+ foreach( $fieldset['fields'] as $key => $field ) :
300
+ ?>
301
+ <tr>
302
+ <th><label for="<?php echo $key; ?>"><?php echo $field['label']; ?></label></th>
303
+ <td>
304
+ <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/>
305
+ <span class="description"><?php echo $field['description']; ?></span>
306
+ </td>
307
+ </tr>
308
+ <?php
309
+ endforeach;
310
+ ?>
311
+ </table>
312
+ <?php
313
+ endforeach;
314
+ echo '</fieldset>';
315
+ }
316
+ }
317
+ function woocommerce_saphali_admin_menu_s_l() {
318
+ add_submenu_page('woocommerce', __('Настройки Saphali WC Lite', 'woocommerce'), __('Saphali WC Lite', 'woocommerce') , 'manage_woocommerce', 'woocommerce_saphali_s_l', array($this,'woocommerce_saphali_page_s_l'));
319
+ }
320
+ function add_inr_currency( $currencies ) {
321
+ $currencies['UAH'] = __( 'Ukrainian hryvnia', 'saphali-woocommerce-lite' );
322
+ $currencies['RUR'] = __( 'Russian ruble', 'saphali-woocommerce-lite' );
323
+ if( version_compare( WOOCOMMERCE_VERSION, '2.5.2', '<' ) || SAPHALI_LITE_SYMBOL )
324
+ $currencies['RUB'] = __( 'Russian ruble', 'saphali-woocommerce-lite' );
325
+ $currencies['BYN'] = sprintf(__( 'Belarusian ruble%s', 'saphali-woocommerce-lite' ), __(' (new)', 'saphali-woocommerce-lite'));
326
+ $currencies['BYR'] = sprintf(__( 'Belarusian ruble%s', 'saphali-woocommerce-lite' ), '');
327
+ $currencies['AMD'] = __( 'Armenian dram (Դրամ)', 'saphali-woocommerce-lite' );
328
+ $currencies['KGS'] = __( 'Киргизский сом', 'saphali-woocommerce-lite' );
329
+ $currencies['KZT'] = __( 'Казахстанский тенге ', 'saphali-woocommerce-lite' );
330
+ $currencies['UZS'] = __( 'Узбекский сум', 'saphali-woocommerce-lite' );
331
+ $currencies['LTL'] = __( 'Lithuanian Litas', 'saphali-woocommerce-lite' );
332
+ return $currencies;
333
+ }
334
+ function add_inr_currency_symbol( $symbol , $currency ) {
335
+ if(empty($currency))
336
+ $currency = get_option( 'woocommerce_currency' );
337
+ if(isset($currency)) {
338
+ if( version_compare( WOOCOMMERCE_VERSION, '2.5.2', '<' ) || SAPHALI_LITE_SYMBOL )
339
+ switch( $currency ) {
340
+ case 'UAH': $symbol = '&#x433;&#x440;&#x43D;.'; break;
341
+ case 'RUB': $symbol = '<span class=rur >&#x440;<span>&#x443;&#x431;.</span></span>'; break;
342
+ case 'RUR': $symbol = '&#x440;&#x443;&#x431;.'; break;
343
+ case 'BYN': $symbol = '&#x440;&#x443;&#x431;.'; break;
344
+ case 'BYR': $symbol = '&#x440;&#x443;&#x431;.'; break;
345
+ case 'AMD': $symbol = '&#x534;'; break;
346
+ case 'KGS': $symbol = 'сом'; break;
347
+ case 'KZT': $symbol = '&#x20B8;'; break;
348
+ case 'UZS': $symbol = '&#x441;&#x45E;&#x43C;'; break;
349
+ case 'LTL': $symbol = 'lt.'; break;
350
+ }
351
+ else
352
+ switch( $currency ) {
353
+ case 'UAH': $symbol = '&#x433;&#x440;&#x43D;.'; break;
354
+ case 'RUR': $symbol = '&#x440;&#x443;&#x431;.'; break;
355
+ case 'BYN': $symbol = '&#x440;&#x443;&#x431;.'; break;
356
+ case 'BYR': $symbol = '&#x440;&#x443;&#x431;.'; break;
357
+ case 'AMD': $symbol = '&#x534;'; break;
358
+ case 'KGS': $symbol = 'сом'; break;
359
+ case 'KZT': $symbol = '&#x20B8;'; break;
360
+ case 'UZS': $symbol = '&#x441;&#x45E;&#x43C;'; break;
361
+ case 'LTL': $symbol = 'lt.'; break;
362
+ }
363
+ }
364
+ return $symbol;
365
+ }
366
+ function admin_enqueue_scripts_page_saphali() {
367
+ global $woocommerce;
368
+ $plugin_url = plugins_url( basename( plugin_dir_path(__FILE__) ), basename( __FILE__ ) );
369
+ if( isset($_GET['page']) && $_GET['page'] == 'woocommerce_saphali_s_l' && (isset($_GET['tab']) && $_GET['tab'] ==1) )
370
+ wp_enqueue_script( 'tablednd', $plugin_url. '/js/jquery.tablednd.0.5.js', array('jquery'), $woocommerce->version );
371
+ }
372
+ function woocommerce_saphali_page_s_l () {
373
+ ?>
374
+ <div class="wrap woocommerce"><div class="icon32 icon32-woocommerce-reports" id="icon-woocommerce"><br /></div>
375
+ <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
376
+ Настройки Saphali WC
377
+ </h2>
378
+ <ul class="subsubsub">
379
+
380
+ <li><a href="admin.php?page=woocommerce_saphali_s_l" <?php if(empty($_GET["tab"])) echo 'class="current"';?>><span color="red">Дополнительная информация</span></a> | </li>
381
+ <li><a href="admin.php?page=woocommerce_saphali_s_l&tab=1" <?php if(!empty($_GET["tab"]) && $_GET["tab"] == 1) echo 'class="current"';?>>Управление полями</a> | </li>
382
+ <li><a href="admin.php?page=woocommerce_saphali_s_l&tab=2" <?php if(!empty($_GET["tab"]) && $_GET["tab"] == 2) echo 'class="current"';?>>Число колонок в каталоге</a></li>
383
+
384
+ </ul>
385
+ <?php if( empty($_GET["tab"]) ) {?>
386
+ <div class="clear"></div>
387
+ <h2 class="woo-nav-tab-wrapper">Дополнительная информация</h2>
388
+ <?php include_once (SAPHALI_PLUGIN_DIR_PATH . 'go_pro.php'); } elseif($_GET["tab"] == 2) {?>
389
+ <div class="clear"></div>
390
+ <h2 class="woo-nav-tab-wrapper">Число колонок в каталоге товаров и в рубриках</h2>
391
+ <?php include_once (SAPHALI_PLUGIN_DIR_PATH . 'count-column.php'); } elseif($_GET["tab"] == 1) {
392
+ global $woocommerce;
393
+ if ( empty( $woocommerce->checkout ) ) {
394
+
395
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.0', '<' ) ) {
396
+ include_once( WP_PLUGIN_DIR . '/' . $woocommerce->template_url. 'classes/class-wc-checkout.php' );
397
+ } elseif ( !version_compare( WOOCOMMERCE_VERSION, '2.3', '<' ) ) {
398
+ include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/class-wc-autoloader.php' );
399
+ $load = new WC_Autoloader();
400
+ if(!class_exists('WC_Customer')) $load->autoload( 'WC_Customer' ); $load->autoload( 'WC_Checkout' ); if ( !version_compare( WOOCOMMERCE_VERSION, '2.2', '<' ) ) { include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/abstracts/abstract-wc-session.php' ); include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/class-wc-session-handler.php' ); $woocommerce->session = new WC_Session_Handler();} else {
401
+ $woocommerce->autoload( 'WC_Session' );
402
+ $woocommerce->autoload( 'WC_Session_Handler' );
403
+ }
404
+ } else {
405
+ if(!class_exists('WC_Customer')) $woocommerce->autoload( 'WC_Customer' ); $woocommerce->autoload( 'WC_Checkout' ); if ( !version_compare( WOOCOMMERCE_VERSION, '2.2', '<' ) ) { include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.2/','compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/abstracts/abstract-wc-session.php' ); include_once( WP_PLUGIN_DIR . '/' . str_replace( array('compatability/2.2/','compatability/2.3/', 'compatibility/2.4/'), '', WC()->template_path() ) . 'includes/class-wc-session-handler.php' ); $woocommerce->session = new WC_Session_Handler();} else {
406
+ $woocommerce->autoload( 'WC_Session' );
407
+ if ( !version_compare( WOOCOMMERCE_VERSION, '2.1', '<' ))
408
+ $woocommerce->autoload( 'WC_Session_Handler' );
409
+ }
410
+ }
411
+ if(class_exists('WC_Checkout')) {
412
+ if(class_exists('WC_Customer')) $woocommerce->customer = new WC_Customer();
413
+ $f = new WC_Checkout();
414
+ }
415
+ }
416
+ else $f = $woocommerce->checkout;
417
+ if($_POST){
418
+ if(@$_POST["reset"] != 'All') {
419
+ // Управление новыми полями
420
+
421
+ if(@is_array($_POST["billing"]["new_fild"])) {
422
+ foreach($_POST["billing"]["new_fild"] as $k_nf => $v_nf) {
423
+ if($k_nf == 'name') {
424
+ foreach($v_nf as $v_nf_f) {
425
+ $new_fild = $v_nf_f;
426
+ }
427
+ }
428
+ else {
429
+ if(is_array($v_nf) )
430
+ foreach($v_nf as $k_nf_f => $v_nf_f) {
431
+ if($k_nf == 'class' ) {
432
+ $v_nf_f = array ( $v_nf_f );
433
+ $addFild["billing"][$new_fild][$k_nf] = $v_nf_f;
434
+ } else $addFild["billing"][$new_fild][$k_nf] = $v_nf_f;
435
+ //$addFild["billing"][$new_fild[$k_nf_f]]['add_new'] = true;
436
+ }
437
+ if($k_nf == 'type' && !is_array($v_nf) || $k_nf == 'options') {
438
+ $addFild["billing"][$new_fild][$k_nf] = $v_nf;
439
+ }
440
+ }
441
+ }
442
+ unset($_POST["billing"]["new_fild"]);
443
+ unset($new_fild);
444
+ }
445
+ if(@is_array($_POST["shipping"]["new_fild"])) {
446
+ foreach($_POST["shipping"]["new_fild"] as $k_nf => $v_nf) {
447
+ if($k_nf == 'name')
448
+ foreach($v_nf as $v_nf_f)
449
+ $new_fild[] = $v_nf_f;
450
+ else {
451
+ foreach($v_nf as $k_nf_f => $v_nf_f) {
452
+ if($k_nf == 'class') {
453
+ $v_nf_f = array ( $v_nf_f );
454
+ $addFild["shipping"][$new_fild[$k_nf_f]][$k_nf] = $v_nf_f;
455
+ } else $addFild["shipping"][$new_fild[$k_nf_f]][$k_nf] = $v_nf_f;
456
+ //$addFild["shipping"][$new_fild[$k_nf_f]]['add_new'] = true;
457
+ }
458
+ }
459
+ }
460
+ unset($_POST["shipping"]["new_fild"]);
461
+ unset($new_fild);
462
+ }
463
+ if(@is_array($_POST["order"]["new_fild"])) {
464
+ foreach($_POST["order"]["new_fild"] as $k_nf => $v_nf) {
465
+ if($k_nf == 'name')
466
+ foreach($v_nf as $v_nf_f)
467
+ $new_fild[] = $v_nf_f;
468
+ else {
469
+ foreach($v_nf as $k_nf_f => $v_nf_f) {
470
+ if($k_nf == 'class') {
471
+ $v_nf_f = array ( $v_nf_f );
472
+ $addFild["order"][$new_fild[$k_nf_f]][$k_nf] = $v_nf_f;
473
+ } else $addFild["order"][$new_fild[$k_nf_f]][$k_nf] = $v_nf_f;
474
+ //$addFild["order"][$new_fild[$k_nf_f]]['add_new'] = true;
475
+ }
476
+ }
477
+ }
478
+ unset($_POST["order"]["new_fild"]);
479
+ }
480
+ //END
481
+ $filds = $f->checkout_fields;
482
+
483
+ if(is_array($filds["billing"])) {
484
+ if(!is_array($addFild["billing"])) $addFild["billing"] = array();
485
+ if(!is_array($_POST["billing"])) $_POST["billing"] = array();
486
+ $filds["billing"] = array_merge($filds["billing"] , $_POST["billing"], $addFild["billing"]);
487
+
488
+ foreach($filds["billing"] as $key_post => $value_post) {
489
+
490
+ if( !isset($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"]);
491
+
492
+
493
+ if(@$filds["billing"][$key_post]['public'] != 'on') {
494
+ $filds_new["billing"][$filds["billing"][$key_post]["order"]][$key_post]["public"] = false;
495
+ $fild_remove_filter["billing"][] = $key_post;
496
+ } else {$filds_new["billing"][$filds["billing"][$key_post]["order"]][$key_post]["public"] = true;}
497
+
498
+
499
+ foreach($value_post as $k_post=> $v_post){
500
+ if( 'on' == $v_post ) {
501
+ $filds["billing"][$key_post][$k_post] = true;
502
+ $value_post[$k_post] = true;
503
+ } elseif(in_array($k_post, array('public','clear','required'))) { $filds["billing"][$key_post][$k_post] = false; $value_post[$k_post] = false; if(!$filds["billing"][$key_post][$k_post] && $k_post == 'public') unset($filds["billing"][$key_post][$k_post]); }
504
+ }
505
+ $filds_new["billing"][$filds["billing"][$key_post]["order"]][$key_post] = $value_post;
506
+
507
+ unset($_POST["billing"][$key_post]);
508
+ }
509
+
510
+ }
511
+ if(is_array($filds["shipping"])) {
512
+ if(!is_array($addFild["shipping"])) $addFild["shipping"] = array();
513
+ if(!is_array($_POST["shipping"])) $_POST["shipping"] = array();
514
+ $filds["shipping"] = array_merge($filds["shipping"] , $_POST["shipping"], $addFild["shipping"]);
515
+ foreach($filds["shipping"] as $key_post => $value_post) {
516
+
517
+ if( !isset($f->checkout_fields["shipping"][$key_post]['type']) ) unset($filds["shipping"][$key_post]['type'], $value_post["type"]);
518
+
519
+ if($filds["shipping"][$key_post]['public'] != 'on') {
520
+ $filds_new["shipping"][$filds["shipping"][$key_post]["order"]][$key_post]["public"] = false;
521
+ $fild_remove_filter["shipping"][] = $key_post;
522
+ } else {$filds_new["shipping"][$filds["shipping"][$key_post]["order"]][$key_post]["public"] = true;}
523
+
524
+ foreach($value_post as $k_post=> $v_post){
525
+ if( 'on' == $v_post ) {
526
+ $filds["shipping"][$key_post][$k_post] = true;
527
+ $value_post[$k_post] = true;
528
+ } elseif(in_array($k_post, array('public','clear','required'))) { $filds["shipping"][$key_post][$k_post] = false; $value_post[$k_post] = false; if(!$filds["shipping"][$key_post][$k_post] && $k_post == 'public') unset($filds["shipping"][$key_post][$k_post]); }
529
+ }
530
+ $filds_new["shipping"][$filds["shipping"][$key_post]["order"]][$key_post] = $value_post;
531
+ unset($_POST["shipping"][$key_post]);
532
+ }
533
+ }
534
+ if(is_array($filds["order"])) {
535
+ if(!is_array($addFild["order"])) $addFild["order"] = array();
536
+ if(!is_array($_POST["order"])) $_POST["order"] = array();
537
+ $filds["order"] = array_merge($filds["order"] , $_POST["order"], $addFild["order"]);
538
+
539
+ foreach($filds["order"] as $key_post => $value_post) {
540
+
541
+ if($filds["order"][$key_post]['public'] != 'on') {
542
+ $filds_new["order"][$filds["order"][$key_post]["order"]][$key_post]["public"] = false;
543
+ $fild_remove_filter["order"][] = $key_post;
544
+ } else {$filds_new["order"][$filds["order"][$key_post]["order"]][$key_post]["public"] = true;}
545
+
546
+ foreach($value_post as $k_post=> $v_post){
547
+ if( 'on' == $v_post ) {
548
+ $filds["order"][$key_post][$k_post] = true;
549
+ $value_post[$k_post] = true;
550
+ } elseif(in_array($k_post, array('public','clear','required'))) { $filds["order"][$key_post][$k_post] = false; $value_post[$k_post] = false; if(!$filds["order"][$key_post][$k_post] && $k_post == 'public') unset($filds["order"][$key_post][$k_post]); }
551
+ }
552
+
553
+ $filds_new["order"][$filds["order"][$key_post]["order"]][$key_post] = $value_post;
554
+
555
+ unset($_POST["order"][$key_post]);
556
+ }
557
+ }
558
+
559
+ //END Управление публикацией
560
+ $filds_finish["billing"] = $filds_finish["shipping"] = $filds_finish["order"] = array();
561
+
562
+ for($i = 0; $i<count($filds_new["billing"]); $i++) {
563
+ if(isset($filds_new["billing"][$i]))
564
+ $filds_finish["billing"] = $filds_finish["billing"] + $filds_new["billing"][$i];
565
+ }
566
+ for($i = 0; $i<count($filds_new["shipping"]); $i++) {
567
+ if(isset($filds_new["shipping"][$i]))
568
+ $filds_finish["shipping"] = $filds_finish["shipping"] + $filds_new["shipping"][$i];
569
+ }
570
+ for($i = 0; $i<count($filds_new["order"]); $i++) {
571
+ if(isset($filds_new["order"][$i]))
572
+ $filds_finish["order"] = $filds_finish["order"] + $filds_new["order"][$i];
573
+ }
574
+
575
+ $filds_finish_filter = $filds_finish;
576
+ if(is_array($fild_remove_filter["billing"])) {
577
+ foreach($fild_remove_filter["billing"] as $v_filt){
578
+ unset($filds_finish_filter["billing"][$v_filt]);
579
+ }
580
+ }
581
+ if(is_array($fild_remove_filter["shipping"])) {
582
+ foreach($fild_remove_filter["shipping"] as $v_filt){
583
+ unset($filds_finish_filter["shipping"][$v_filt]);
584
+ }
585
+ }
586
+ if(is_array($fild_remove_filter["order"])) {
587
+ foreach($fild_remove_filter["order"] as $v_filt){
588
+ unset($filds_finish_filter["order"][$v_filt]);
589
+ }
590
+ }
591
+ if(!update_option('woocommerce_saphali_filds',$filds_finish))add_option('woocommerce_saphali_filds',$filds_finish);
592
+ if(!update_option('woocommerce_saphali_filds_filters',$filds_finish_filter))add_option('woocommerce_saphali_filds_filters',$filds_finish_filter);
593
+ foreach($filds_finish_filter['billing'] as $k_f => $v_f) {
594
+ $new_key = str_replace('billing_', '' , $k_f);
595
+ if(in_array($new_key, array('country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ) ))
596
+ $locate[$new_key] = $v_f;
597
+ elseif(in_array(str_replace('shipping_', '' , $k_f), array('country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ) )) {
598
+ $locate[$new_key] = $filds_finish_filter['shipping'][$k_f];
599
+ }
600
+ }
601
+ if(!update_option('woocommerce_saphali_filds_locate',$locate))add_option('woocommerce_saphali_filds_locate',$locate);
602
+ } else {
603
+ delete_option('woocommerce_saphali_filds');
604
+ delete_option('woocommerce_saphali_filds_filters');
605
+ delete_option('woocommerce_saphali_filds_locate');
606
+ }
607
+ }
608
+
609
+ ?>
610
+ <div class="clear"></div>
611
+ <h3 class="nav-tab-wrapper woo-nav-tab-wrapper" style="text-align: center;">Управление полями на странице заказа и на странице профиля</h3>
612
+ <?php if($_POST && @$_POST["reset"] != 'All') { ?><div class="updated" id="message"><p>Настройки сохранены</p></div><?php } ?>
613
+ <h2 align="center">Реквизиты оплаты</h2>
614
+ <form action="" method="post">
615
+ <table class="wp-list-table widefat fixed posts" cellspacing="0">
616
+ <thead>
617
+ <tr>
618
+ <th width="130px">Название<img class="help_tip" data-tip="Название поля должно быть уни&shy;ка&shy;ль&shy;ным (не должно повторяться)." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
619
+ <th width="130px">Заголовок</th>
620
+ <th width="130px">Текст в поле</th>
621
+ <th width="35px">Clear<img class="help_tip" data-tip="Указывает на то, что следующее поле за текущим, будет начинаться с новой строки." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /> </th>
622
+ <th width="130px">Класс поля<img class="help_tip" data-tip="<h3 style='margin:0;padding:0'>Задает стиль текущего поля</h3><ul style='text-align: left;'><li><span style='color: #000'>form-row-first</span>&nbsp;&ndash;&nbsp;первый в строке;</li><li><span style='color: #000'>form-row-last</span>&nbsp;&ndash;&nbsp;последний в строке.</li></ul><hr /><span style='color: #000'>ЕСЛИ ОСТАВИТЬ ПУСТЫМ</span>, то поле будет отображаться на всю ширину. Соответственно, в предыдущем поле (которое выше) нужно отметить &laquo;Clear&raquo;." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
623
+ <th width="40px">Тип поля</th>
624
+ <th width="40px">Обя&shy;за&shy;те&shy;ль&shy;ное</th>
625
+
626
+ <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
627
+
628
+ <th width="65px">Удалить/До&shy;ба&shy;вить</th>
629
+ </tr>
630
+ </thead>
631
+ <tfoot>
632
+ <tr>
633
+ <th>Название</th>
634
+ <th>Заголовок</th>
635
+ <th>Текст в поле</th>
636
+ <th width="35px">Clear<img class="help_tip" data-tip="Указывает на то, что следующее поле за текущим, будет начинаться с новой строки." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /> </th>
637
+ <th>Класс поля</th>
638
+ <th width="40px">Тип поля</th>
639
+ <th width="40px">Обя&shy;за&shy;те&shy;ль&shy;ное</th>
640
+
641
+ <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
642
+
643
+ <th>Удалить/До&shy;ба&shy;вить</th>
644
+ </tr>
645
+ </tfoot>
646
+ <tbody id="the-list" class="myTable">
647
+ <?php
648
+
649
+ $count = 0;
650
+
651
+ $checkout_fields = get_option('woocommerce_saphali_filds');
652
+
653
+ if( isset($checkout_fields["billing"]) && is_array($checkout_fields["billing"])) $f->checkout_fields["billing"] = $checkout_fields["billing"];
654
+ if( isset($f) )
655
+ foreach($f->checkout_fields["billing"] as $key => $value) {
656
+ $public = 'public';
657
+ if( !version_compare( WOOCOMMERCE_VERSION, '3.0', '<' ) ) {
658
+ if( isset( $checkout_fields["billing"][$key] ) ) $value[$public] = $checkout_fields["billing"][$key][$public];
659
+ }
660
+
661
+ if(empty($value[$public]) && !is_array($checkout_fields["billing"])) $value[$public] = true;
662
+ ?>
663
+ <tr>
664
+ <td> <input disabled value='<?php echo $key?>' type="text" name="billing[<?php echo $key?>][name]" /></td>
665
+ <td><input value='<?php echo $value['label']?>' type="text" name="billing[<?php echo $key?>][label]" /></td>
666
+ <td<?php if(isset($value['type']) && $value['type'] == 'select') {echo ' class="option-area"';} ?>><?php if(!isset($value['type']) || isset($value['type']) && $value['type'] != 'select') { ?><input value='<?php if(isset( $value['placeholder'] )) echo $value['placeholder']; ?>' type="text" name="billing[<?php echo $key?>][placeholder]" /><?php } else {
667
+ if( isset($value['options']) && is_array($value['options']) ) {
668
+ foreach($value['options'] as $key_option => $val_option) {?>
669
+ <span><input id="options" type="text" name="billing[<?php echo $key?>][options][<?php echo $key_option; ?>]" value="<?php echo $val_option?>" /> <span class="delete-option" style="cursor:pointer;border:1px solid">Удалить</span></span><br />
670
+
671
+ <?php } ?>
672
+ <div class="button add_option" rel="<?php echo $key; ?>">Добавить еще</div>
673
+ <?php
674
+ }
675
+
676
+ } ?></td>
677
+ <td><input <?php if(isset($value['clear']) && $value['clear']) echo 'checked'?> class="<?php echo isset($value['clear']) ? $value['clear'] : '' ;?>" type="checkbox" name="billing[<?php echo $key?>][clear]" /></td>
678
+ <td><?php if(isset($value['class']) && is_array($value['class'])) { foreach($value['class'] as $v_class) { ?>
679
+ <input value='<?php echo $v_class;?>' type="text" name="billing[<?php echo $key?>][class][]" /> <?php } } else { ?>
680
+ <input value='' type="text" name="billing[<?php echo $key?>][class][]" /> <?php
681
+ } ?></td>
682
+ <td>
683
+ Select <input <?php if(isset($value['type']) && $value['type'] == 'select') echo 'checked'?> type="radio" name="billing[<?php echo $key?>][type]" value="select" /><br />
684
+ Checkbox <input <?php if(isset($value['type']) && $value['type'] == 'checkbox') echo 'checked'?> type="radio" name="billing[<?php echo $key?>][type]" value="checkbox" /><br />
685
+ Textarea <input <?php if(isset($value['type']) && $value['type'] == 'textarea') echo 'checked'?> type="radio" name="billing[<?php echo $key?>][type]" value="textarea" /><br />
686
+ <?php echo (!isset($value['type']) || $value['type'] == 'select'|| $value['type'] == 'checkbox'|| $value['type'] == 'textarea') ? 'Text' : $value['type']; ?> <input <?php if(isset($value['type']) && $value['type'] == $value['type'] && $value['type'] != 'select'&& $value['type'] != 'textarea'&& $value['type'] != 'checkbox') echo 'checked'?> type="radio" name="billing[<?php echo $key?>][type]" value="<?php if( isset($value['type']) && $value['type'] != 'select' && $value['type'] != 'textarea'&& $value['type'] != 'checkbox') echo $value['type']; ?>" />
687
+ </td>
688
+ <td><input <?php if( isset($value['required'] ) && $value['required']) echo 'checked'?> type="checkbox" name="billing[<?php echo $key?>][required]" /></td>
689
+ <td><input <?php if(isset($value[$public]) && $value[$public]) echo 'checked';?> type="checkbox" name="billing[<?php echo $key?>][<?php echo $public; ?>]" /></td>
690
+
691
+ <td><input rel="sort_order" id="order_count" type="hidden" name="billing[<?php echo $key?>][order]" value="<?php echo $count?>" />
692
+ <input type="button" class="button" id="billing_delete" value="Удалить -"/></td>
693
+ </tr>
694
+ <?php $count++;
695
+ }
696
+ ?>
697
+ <tr class="nodrop nodrag">
698
+ <td></td>
699
+ <td></td>
700
+ <td></td>
701
+ <td></td>
702
+ <td></td>
703
+ <td></td>
704
+
705
+ <td></td>
706
+
707
+ <td><input type="button" class="button" id="billing" value="Добавить +"/></td>
708
+ </tr>
709
+ </tbody>
710
+ </table>
711
+
712
+ <h2 align="center">Реквизиты доставки</h2>
713
+ <table class="wp-list-table widefat fixed posts" cellspacing="0">
714
+ <thead>
715
+ <tr>
716
+ <th width="130px">Название<img class="help_tip" data-tip="Название поля должно быть уни&shy;ка&shy;ль&shy;ным (не должно повторяться)." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
717
+ <th width="130px">Заголовок</th>
718
+ <th width="130px">Текст в поле</th>
719
+ <th width="35px">Clear<img class="help_tip" data-tip="Указывает на то, что следующее поле за текущим, будет начинаться с новой строки." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /> </th>
720
+ <th width="130px">Класс поля<img class="help_tip" data-tip="<h3 style='margin:0;padding:0'>Задает стиль текущего поля</h3><ul style='text-align: left;'><li><span style='color: #000'>form-row-first</span>&nbsp;&ndash;&nbsp;первый в строке;</li><li><span style='color: #000'>form-row-last</span>&nbsp;&ndash;&nbsp;последний в строке.</li></ul><hr /><span style='color: #000'>ЕСЛИ ОСТАВИТЬ ПУСТЫМ</span>, то поле будет отображаться на всю ширину. Соответственно, в предыдущем поле (которое выше) нужно отметить &laquo;Clear&raquo;." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
721
+ <th width="40px">Обя&shy;за&shy;те&shy;ль&shy;ное</th>
722
+
723
+ <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
724
+
725
+ <th width="65px">Удалить/До&shy;ба&shy;вить</th>
726
+ </tr>
727
+ </thead>
728
+ <tfoot>
729
+ <tr>
730
+ <th>Название</th>
731
+ <th>Заголовок</th>
732
+ <th>Текст в поле</th>
733
+ <th width="56px">Clear<img class="help_tip" data-tip="Указывает на то, что следующее поле за текущим, будет начинаться с новой строки." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /> </th>
734
+ <th>Класс поля</th>
735
+ <th width="40px">Обя&shy;за&shy;те&shy;ль&shy;ное</th>
736
+
737
+ <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
738
+
739
+ <th>Удалить/До&shy;ба&shy;вить</th>
740
+ </tr>
741
+ </tfoot>
742
+ <tbody id="the-list" class="myTable">
743
+ <?php $count = 0;
744
+ if(isset($checkout_fields["shipping"]) && is_array($checkout_fields["shipping"])) $f->checkout_fields["shipping"] = $checkout_fields["shipping"];
745
+ if( isset( $f->checkout_fields["shipping"] ) )
746
+ foreach($f->checkout_fields["shipping"] as $key => $value) {
747
+ $public = 'public';
748
+ if( ! version_compare( WOOCOMMERCE_VERSION, '3.0', '<' ) ) {
749
+ if( isset( $checkout_fields["shipping"][$key] ) ) $value[$public] = $checkout_fields["shipping"][$key][$public];
750
+ }
751
+ if( empty($value['public']) && !is_array($checkout_fields["shipping"]) ) $value['public'] = true;
752
+ ?>
753
+ <tr>
754
+ <td><input disabled value=<?php echo $key?> type="text" name="shipping[<?php echo $key?>][name]" /></td>
755
+ <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>
756
+ <td><input value='<?php if(isset( $value['placeholder'] )) echo $value['placeholder']; ?>' type="text" name="shipping[<?php echo $key?>][placeholder]" /></td>
757
+ <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>
758
+ <td><?php if( isset($value['class']) && is_array($value['class']) ) { foreach($value['class'] as $v_class) { ?>
759
+
760
+ <input value='<?php echo $v_class;?>' type="text" name="shipping[<?php echo $key?>][class][]" /> <?php } } else { ?>
761
+ <input value='' type="text" name="shipping[<?php echo $key?>][class][]" /> <?php
762
+ } ?></td>
763
+ <td><input <?php if(isset($value['required']) && $value['required']) echo 'checked'?> type="checkbox" name="shipping[<?php echo $key?>][required]" /></td>
764
+ <td><input <?php if(isset($value['public']) && $value['public']) echo 'checked';?> type="checkbox" name="shipping[<?php echo $key?>][public]" /></td>
765
+
766
+ <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="Удалить -"/>
767
+ <?php
768
+ if( isset($value['options']) && is_array($value['options']) ) {
769
+ foreach($value['options'] as $key_option => $val_option) {?>
770
+ <input id="options" type="hidden" name="shipping[<?php echo $key?>][options][<?php echo $key_option; ?>]" value="<?php echo $val_option?>" />
771
+ <?php }
772
+ } ?>
773
+ </td>
774
+ </tr>
775
+ <?php $count++;
776
+ }
777
+ ?>
778
+ <tr class="nodrop nodrag">
779
+ <td></td>
780
+ <td></td>
781
+ <td></td>
782
+
783
+ <td></td>
784
+ <td></td>
785
+ <td></td>
786
+ <td></td>
787
+
788
+ <td><input type="button" class="button" id="shipping" value="Добавить +"/></td>
789
+ </tr>
790
+
791
+ </tbody>
792
+ </table>
793
+ <br />
794
+ <h2 align="center">Дополнительные поля</h2>
795
+ <table class="wp-list-table widefat fixed posts" cellspacing="0">
796
+ <thead>
797
+ <tr>
798
+ <th width="130px">Название<img class="help_tip" data-tip="Название поля должно быть уни&shy;ка&shy;ль&shy;ным (не должно повторяться)." src="<?php bloginfo('wpurl');?>/wp-content/plugins/woocommerce/assets/images/help.png" /></th>
799
+ <th width="130px">Заголовок</th>
800
+ <th width="130px">Текст в поле</th>
801
+ <th width="130px">Класс поля</th>
802
+ <th width="130px">Тип поля</th>
803
+ <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
804
+
805
+ <th width="65px">Удалить/До&shy;ба&shy;вить</th>
806
+ </tr>
807
+ </thead>
808
+ <tfoot>
809
+ <tr>
810
+ <th>Название</th>
811
+ <th>Заголовок</th>
812
+ <th>Текст в поле</th>
813
+ <th>Класс поля</th>
814
+ <th>Тип поля</th>
815
+ <th width="40px">Опу&shy;бли&shy;ко&shy;вать</th>
816
+
817
+ <th>Удалить/До&shy;ба&shy;вить</th>
818
+ </tr>
819
+ </tfoot>
820
+ <tbody id="the-list" class="myTable">
821
+ <?php $count = 0;
822
+ if(isset($checkout_fields["order"]) && is_array($checkout_fields["order"])) $f->checkout_fields["order"] = $checkout_fields["order"];
823
+ if(isset($f->checkout_fields["order"]) )
824
+ foreach($f->checkout_fields["order"] as $key => $value) {
825
+ $public = 'public';
826
+ if( ! version_compare( WOOCOMMERCE_VERSION, '3.0', '<' ) ) {
827
+ if( isset( $checkout_fields["order"][$key] ) ) $value[$public] = $checkout_fields["order"][$key][$public];
828
+ }
829
+ if(empty($value['public']) && !is_array($checkout_fields["order"])) $value['public'] = true;
830
+ ?>
831
+ <tr>
832
+ <td><input disabled value=<?php echo $key?> type="text" name="order[<?php echo $key?>][name]" /></td>
833
+ <td><input value='<?php echo $value['label']?>' type="text" name="order[<?php echo $key?>][label]" /></td>
834
+ <td><input value='<?php echo $value['placeholder']?>' type="text" name="order[<?php echo $key?>][placeholder]" /></td>
835
+
836
+ <td><?php if(isset($value['class']) && is_array($value['class'])) { foreach($value['class'] as $v_class) { ?>
837
+
838
+ <input value='<?php echo $v_class;?>' type="text" name="order[<?php echo $key?>][class][]" /> <?php } } else { ?>
839
+ <input value='' type="text" name="order[<?php echo $key?>][class][]" /> <?php
840
+ } ?></td>
841
+ <td><input value='<?php echo $value['type']?>' type="text" name="order[<?php echo $key?>][type]" /></td>
842
+ <td><input <?php if($value['public']) echo 'checked';?> type="checkbox" name="order[<?php echo $key?>][public]" /></td>
843
+
844
+ <td><input id="order_count" rel="sort_order" type="hidden" name="order[<?php echo $key?>][order]" value="<?php echo $count?>" /><input type="button" class="button" id="billing_delete" value="Удалить -"/>
845
+ <?php
846
+ if( isset($value['options']) && is_array($value['options']) ) {
847
+ foreach($value['options'] as $key_option => $val_option) {?>
848
+ <input id="options" type="hidden" name="order[<?php echo $key?>][options][<?php echo $key_option; ?>]" value="<?php echo $val_option?>" />
849
+ <?php }
850
+ } ?>
851
+ </td>
852
+ </tr>
853
+ <?php $count++;
854
+ }
855
+ ?>
856
+ <tr class="nodrop nodrag">
857
+ <td></td>
858
+ <td></td>
859
+ <td></td>
860
+ <td></td>
861
+ <td></td>
862
+ <td></td>
863
+
864
+
865
+ <td><input type="button" class="button" id="order" value="Добавить +"/></td>
866
+ </tr>
867
+ </tbody>
868
+ </table><br />
869
+ <input type="submit" class="button alignleft" value="Сохранить"/>
870
+ </form>
871
+ <form action="" method="post">
872
+ <input type="hidden" name="reset" value="All"/>
873
+ <input type="submit" class="button alignright" value="Восстановить поля по умолчанию"/>
874
+ </form>
875
+ <style type="text/css">
876
+ #tiptip_content{font-size:11px;color:#fff;padding:4px 8px;background:#a2678c;border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;box-shadow:1px 1px 3px rgba(0,0,0,0.1);-webkit-box-shadow:1px 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:1px 1px 3px rgba(0,0,0,0.1);text-align:center}#tiptip_content code{background:#855c76;padding:1px}#tiptip_arrow,#tiptip_arrow_inner{position:absolute;border-color:transparent;border-style:solid;border-width:6px;height:0;width:0}#tiptip_holder.tip_top #tiptip_arrow_inner{margin-top:-7px;margin-left:-6px;border-top-color:#a2678c}#tiptip_holder.tip_bottom #tiptip_arrow_inner{margin-top:-5px;margin-left:-6px;border-bottom-color:#a2678c}#tiptip_holder.tip_right #tiptip_arrow_inner{margin-top:-6px;margin-left:-5px;border-right-color:#a2678c}#tiptip_holder.tip_left #tiptip_arrow_inner{margin-top:-6px;margin-left:-7px;border-left-color:#a2678c}img.help_tip{vertical-align:middle;margin:0 0 0 3px}#tiptip_holder{display:none;position:absolute;top:0;left:0;z-index:99999}#tiptip_holder.tip_top{padding-bottom:5px}#tiptip_holder.tip_bottom{padding-top:5px}#tiptip_holder.tip_right{padding-left:5px}#tiptip_holder.tip_left{padding-right:5px}#tiptip_content{font-size:11px;color:#fff;padding:4px 8px;background:#a2678c;border-radius:3px;-webkit-border-radius:3px;-moz-border-radius:3px;box-shadow:1px 1px 3px rgba(0,0,0,0.1);-webkit-box-shadow:1px 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:1px 1px 3px rgba(0,0,0,0.1);text-align:center}#tiptip_content code{background:#855c76;padding:1px}#tiptip_arrow,#tiptip_arrow_inner{position:absolute;border-color:transparent;border-style:solid;border-width:6px;height:0;width:0}#tiptip_holder.tip_top #tiptip_arrow_inner{margin-top:-7px;margin-left:-6px;border-top-color:#a2678c}#tiptip_holder.tip_bottom #tiptip_arrow_inner{margin-top:-5px;margin-left:-6px;border-bottom-color:#a2678c}#tiptip_holder.tip_right #tiptip_arrow_inner{margin-top:-6px;margin-left:-5px;border-right-color:#a2678c}#tiptip_holder.tip_left #tiptip_arrow_inner{margin-top:-6px;margin-left:-7px;border-left-color:#a2678c}
877
+ input[disabled="disabled"], input[disabled=""] {
878
+ background:none repeat scroll 0 0 #EAEAEA !important;
879
+ color:#636060 !important;
880
+ }
881
+
882
+ </style>
883
+ <script type="text/javascript">
884
+ (function($){$.fn.tipTip=function(options){var defaults={activation:"hover",keepAlive:false,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:false,enter:function(){},exit:function(){}};var opts=$.extend(defaults,options);if($("#tiptip_holder").length<=0){var tiptip_holder=$('<div id="tiptip_holder" style="max-width:'+opts.maxWidth+';"></div>');var tiptip_content=$('<div id="tiptip_content"></div>');var tiptip_arrow=$('<div id="tiptip_arrow"></div>');$("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="tiptip_arrow_inner"></div>')))}else{var tiptip_holder=$("#tiptip_holder");var tiptip_content=$("#tiptip_content");var tiptip_arrow=$("#tiptip_arrow")}return this.each(function(){var org_elem=$(this);if(opts.content){var org_title=opts.content}else{var org_title=org_elem.attr(opts.attribute)}if(org_title!=""){if(!opts.content){org_elem.removeAttr(opts.attribute)}var timeout=false;if(opts.activation=="hover"){org_elem.hover(function(){active_tiptip()},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}else if(opts.activation=="focus"){org_elem.focus(function(){active_tiptip()}).blur(function(){deactive_tiptip()})}else if(opts.activation=="click"){org_elem.click(function(){active_tiptip();return false}).hover(function(){},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}function active_tiptip(){opts.enter.call(this);tiptip_content.html(org_title);tiptip_holder.hide().removeAttr("class").css("margin","0");tiptip_arrow.removeAttr("style");var top=parseInt(org_elem.offset()['top']);var left=parseInt(org_elem.offset()['left']);var org_width=parseInt(org_elem.outerWidth());var org_height=parseInt(org_elem.outerHeight());var tip_w=tiptip_holder.outerWidth();var tip_h=tiptip_holder.outerHeight();var w_compare=Math.round((org_width-tip_w)/2);var h_compare=Math.round((org_height-tip_h)/2);var marg_left=Math.round(left+w_compare);var marg_top=Math.round(top+org_height+opts.edgeOffset);var t_class="";var arrow_top="";var arrow_left=Math.round(tip_w-12)/2;if(opts.defaultPosition=="bottom"){t_class="_bottom"}else if(opts.defaultPosition=="top"){t_class="_top"}else if(opts.defaultPosition=="left"){t_class="_left"}else if(opts.defaultPosition=="right"){t_class="_right"}var right_compare=(w_compare+left)<parseInt($(window).scrollLeft());var left_compare=(tip_w+left)>parseInt($(window).width());if((right_compare&&w_compare<0)||(t_class=="_right"&&!left_compare)||(t_class=="_left"&&left<(tip_w+opts.edgeOffset+5))){t_class="_right";arrow_top=Math.round(tip_h-13)/2;arrow_left=-12;marg_left=Math.round(left+org_width+opts.edgeOffset);marg_top=Math.round(top+h_compare)}else if((left_compare&&w_compare<0)||(t_class=="_left"&&!right_compare)){t_class="_left";arrow_top=Math.round(tip_h-13)/2;arrow_left=Math.round(tip_w);marg_left=Math.round(left-(tip_w+opts.edgeOffset+5));marg_top=Math.round(top+h_compare)}var top_compare=(top+org_height+opts.edgeOffset+tip_h+8)>parseInt($(window).height()+$(window).scrollTop());var bottom_compare=((top+org_height)-(opts.edgeOffset+tip_h+8))<0;if(top_compare||(t_class=="_bottom"&&top_compare)||(t_class=="_top"&&!bottom_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_top"}else{t_class=t_class+"_top"}arrow_top=tip_h;marg_top=Math.round(top-(tip_h+5+opts.edgeOffset))}else if(bottom_compare|(t_class=="_top"&&bottom_compare)||(t_class=="_bottom"&&!top_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_bottom"}else{t_class=t_class+"_bottom"}arrow_top=-12;marg_top=Math.round(top+org_height+opts.edgeOffset)}if(t_class=="_right_top"||t_class=="_left_top"){marg_top=marg_top+5}else if(t_class=="_right_bottom"||t_class=="_left_bottom"){marg_top=marg_top-5}if(t_class=="_left_top"||t_class=="_left_bottom"){marg_left=marg_left+5}tiptip_arrow.css({"margin-left":arrow_left+"px","margin-top":arrow_top+"px"});tiptip_holder.css({"margin-left":marg_left+"px","margin-top":marg_top+"px"}).attr("class","tip"+t_class);if(timeout){clearTimeout(timeout)}timeout=setTimeout(function(){tiptip_holder.stop(true,true).fadeIn(opts.fadeIn)},opts.delay)}function deactive_tiptip(){opts.exit.call(this);if(timeout){clearTimeout(timeout)}tiptip_holder.fadeOut(opts.fadeOut)}}})}})(jQuery);
885
+ jQuery(".tips, .help_tip").tipTip({
886
+ 'attribute' : 'data-tip',
887
+ 'fadeIn' : 50,
888
+ 'fadeOut' : 50,
889
+ 'delay' : 200
890
+ });
891
+ jQuery('input[value="billing_booking_delivery_t"]').parent().parent().hide();
892
+ jQuery('.delete-option').live('click',function() {
893
+ jQuery(this).parent().remove();
894
+ });
895
+ jQuery('.button.add_option').live('click',function() {
896
+ jQuery(this).before(' <span><br /><input type="text" id="options" value="" name="billing['+jQuery(this).attr('rel')+'][options][option-'+ (jQuery(this).parent().find('input').length + 1) +']"/><span class="delete-option" style="cursor:pointer;border:1px solid">Удалить</span></span>');
897
+ });
898
+ jQuery('input[type="radio"]').live('click',function() {
899
+ if( jQuery(this).val() == 'select' || jQuery(this).val() == 'radio') {
900
+ jQuery(this).parent().parent().find('td').css('border-bottom', 'none');
901
+ jQuery(this).parent().parent().addClass('parrent_td_option'+jQuery('.button.add_option').length);
902
+ if('billing[new_fild][name][]' != jQuery(this).parent().parent().find('td:first input').attr('name') )
903
+ jQuery(this).parent().parent().after('<tr style="border-top:0" class="tr_td_option'+jQuery('.button.add_option').length +'" ><td style="border-top:0;padding-left: 72%;" colspan="9"> <span><input id="options" type="text" value="" name="billing['+jQuery(this).parent().parent().find('td:first input').val()+'][options][option-1]"/><span class="delete-option" style="cursor:pointer;border:1px solid">Удалить</span></span> <div class="button add_option" rel="'+jQuery(this).parent().parent().find('td:first input').val()+'">Добавить еще</div></td></tr>');
904
+ else jQuery(this).parent().parent().after('<tr style="border-top:0" class="tr_td_option'+jQuery('.button.add_option').length +'" ><td style="border-top:0;padding-left: 72%;" colspan="9"> <span><input id="options" type="text" value="" name="billing[new_fild][options][option-1]"/><span class="delete-option" style="cursor:pointer;border:1px solid">Удалить</span></span> <div class="button add_option" rel="new_fild">Добавить еще</div></td></tr>');
905
+ } else {
906
+ if(jQuery(this).parent().parent().find('td').attr('style') != '') {
907
+ jQuery(this).parent().parent().find('td').attr('style', '');
908
+ var text = jQuery(this).parent().parent().attr('class');//parrent_td_option
909
+ text = text.replace(/parrent_td_option/g,'');
910
+ jQuery('tr.tr_td_option'+text).remove();
911
+ jQuery(this).parent().parent().attr('class', '');
912
+ }
913
+ }
914
+ });
915
+
916
+ jQuery('input#options').live('blur', function() {
917
+ var text = jQuery(this).attr('name');
918
+ text = text.replace(/\[options\]\[(.*)\]/g,'[options]['+ jQuery(this).val() +']');
919
+ jQuery(this).attr('name', text);
920
+ });
921
+ jQuery('.button#billing').live('click',function() {
922
+ var obj = jQuery(this).parent().parent();
923
+ 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><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>');
924
+ obj.removeClass('nodrop nodrag');
925
+ 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>');
926
+ });
927
+ jQuery('.button#shipping').live('click',function() {
928
+ var obj = jQuery(this).parent().parent();
929
+ 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>');
930
+ obj.removeClass('nodrop nodrag');
931
+ 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>');
932
+ });
933
+ jQuery('.button#order').live('click',function() {
934
+ var obj = jQuery(this).parent().parent();
935
+ 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>');
936
+ obj.removeClass('nodrop nodrag');
937
+ 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>');
938
+ });
939
+
940
+ jQuery('.button#billing_delete').live('click',function() {
941
+ var obj = jQuery(this).parent().parent();
942
+ var obj_r = obj.parent();
943
+ obj.remove();
944
+ obj_r.find("tr").each(function(i, e){
945
+ jQuery(e).find("td input#order_count").val(i);
946
+ });
947
+ });
948
+ jQuery(document).ready(function() {
949
+ jQuery(".myTable").tableDnD({
950
+ onDragClass: "sorthelper",
951
+ onDrop: function(table, row) {
952
+ var data = new Object();
953
+ data.data = new Object();
954
+ data.key = jQuery(table).find("tr td input").attr("rel");
955
+ jQuery(row).fadeOut("fast").fadeIn("slow");
956
+
957
+ jQuery(table).find("tr").each(function(i, e){
958
+ var id = jQuery(e).find("td input#order_count").attr("id");
959
+ data.data[i] = id;
960
+ jQuery(e).find("td input#order_count").val(i);
961
+ });
962
+ }
963
+ });
964
+ });
965
+ </script>
966
+ <?php } ?>
967
+
968
+ </div>
969
+ <?php
970
+ }
971
+ function woocommerce_get_customer_meta_fields_saph_ed() {
972
+ $show_fields = apply_filters('woocommerce_customer_meta_fields', array(
973
+ 'billing' => array(
974
+ 'title' => __('Customer Billing Address', 'woocommerce'),
975
+ 'fields' => array(
976
+ 'billing_first_name' => array(
977
+ 'label' => __('First name', 'woocommerce'),
978
+ 'description' => ''
979
+ ),
980
+ 'billing_last_name' => array(
981
+ 'label' => __('Last name', 'woocommerce'),
982
+ 'description' => ''
983
+ ),
984
+ 'billing_company' => array(
985
+ 'label' => __('Company', 'woocommerce'),
986
+ 'description' => ''
987
+ ),
988
+ 'billing_address_1' => array(
989
+ 'label' => __('Address 1', 'woocommerce'),
990
+ 'description' => ''
991
+ ),
992
+ 'billing_address_2' => array(
993
+ 'label' => __('Address 2', 'woocommerce'),
994
+ 'description' => ''
995
+ ),
996
+ 'billing_city' => array(
997
+ 'label' => __('City', 'woocommerce'),
998
+ 'description' => ''
999
+ ),
1000
+ 'billing_postcode' => array(
1001
+ 'label' => __('Postcode', 'woocommerce'),
1002
+ 'description' => ''
1003
+ ),
1004
+ 'billing_state' => array(
1005
+ 'label' => __('State/County', 'woocommerce'),
1006
+ 'description' => __('Country or state code', 'woocommerce'),
1007
+ ),
1008
+ 'billing_country' => array(
1009
+ 'label' => __('Country', 'woocommerce'),
1010
+ 'description' => __('2 letter Country code', 'woocommerce'),
1011
+ ),
1012
+ 'billing_phone' => array(
1013
+ 'label' => __('Telephone', 'woocommerce'),
1014
+ 'description' => ''
1015
+ ),
1016
+ 'billing_email' => array(
1017
+ 'label' => __('Email', 'woocommerce'),
1018
+ 'description' => ''
1019
+ )
1020
+ )
1021
+ ),
1022
+ 'shipping' => array(
1023
+ 'title' => __('Customer Shipping Address', 'woocommerce'),
1024
+ 'fields' => array(
1025
+ 'shipping_first_name' => array(
1026
+ 'label' => __('First name', 'woocommerce'),
1027
+ 'description' => ''
1028
+ ),
1029
+ 'shipping_last_name' => array(
1030
+ 'label' => __('Last name', 'woocommerce'),
1031
+ 'description' => ''
1032
+ ),
1033
+ 'shipping_company' => array(
1034
+ 'label' => __('Company', 'woocommerce'),
1035
+ 'description' => ''
1036
+ ),
1037
+ 'shipping_address_1' => array(
1038
+ 'label' => __('Address 1', 'woocommerce'),
1039
+ 'description' => ''
1040
+ ),
1041
+ 'shipping_address_2' => array(
1042
+ 'label' => __('Address 2', 'woocommerce'),
1043
+ 'description' => ''
1044
+ ),
1045
+ 'shipping_city' => array(
1046
+ 'label' => __('City', 'woocommerce'),
1047
+ 'description' => ''
1048
+ ),
1049
+ 'shipping_postcode' => array(
1050
+ 'label' => __('Postcode', 'woocommerce'),
1051
+ 'description' => ''
1052
+ ),
1053
+ 'shipping_state' => array(
1054
+ 'label' => __('State/County', 'woocommerce'),
1055
+ 'description' => __('State/County or state code', 'woocommerce')
1056
+ ),
1057
+ 'shipping_country' => array(
1058
+ 'label' => __('Country', 'woocommerce'),
1059
+ 'description' => __('2 letter Country code', 'woocommerce')
1060
+ )
1061
+ )
1062
+ )
1063
+ ));
1064
+ return $show_fields;
1065
+ }
1066
+ function woocommerce_get_customer_meta_fields_saphali() {
1067
+ $fieldss = get_option('woocommerce_saphali_filds_filters');
1068
+
1069
+ $show_fields = $this->woocommerce_get_customer_meta_fields_saph_ed();
1070
+
1071
+
1072
+
1073
+ if(is_array($fieldss)) {
1074
+ if(is_array($fieldss["billing"])) {
1075
+ $billing = array();
1076
+ foreach($fieldss["billing"] as $key => $value) {
1077
+ if(isset($show_fields["billing"]['fields'][$key])) continue;
1078
+
1079
+ foreach($value as $k_post=> $v_post){
1080
+ if( 'on' == $v_post ) {
1081
+ $value[$k_post] = true;
1082
+ } elseif(in_array($k_post, array('public','clear','required'))) { $value[$k_post] = false; }
1083
+ }
1084
+ $billing = array_merge( $billing , array ($key => $value));
1085
+ }
1086
+ }
1087
+ if(is_array($fieldss["shipping"])) {
1088
+ $shipping = array();
1089
+ foreach($fieldss["shipping"] as $key => $value) {
1090
+ if(isset($show_fields["shipping"]['fields'][$key])) continue;
1091
+ foreach($value as $k_post=> $v_post){
1092
+ if( 'on' == $v_post ) {
1093
+ $value[$k_post] = true;
1094
+ } elseif(in_array($k_post, array('public','clear','required'))) { $value[$k_post] = false; }
1095
+ }
1096
+ $shipping = array_merge( $shipping , array ($key => $value));
1097
+ }
1098
+ }
1099
+ if(is_array($fieldss["order"])) {
1100
+ $orders = array();
1101
+ foreach($fieldss["order"] as $key => $value) {
1102
+ if(isset($show_fields["order"]['fields'][$key])) continue;
1103
+ foreach($value as $k_post=> $v_post){
1104
+ if( 'on' == $v_post ) {
1105
+ $value[$k_post] = true;
1106
+ } elseif(in_array($k_post, array('public','clear','required'))) { $value[$k_post] = false; }
1107
+ }
1108
+ $orders = array_merge( $orders , array ($key => $value));
1109
+ }
1110
+ }
1111
+ }
1112
+
1113
+ if(!isset($show_fields['billing']['title'])) {
1114
+ $_show_fields['billing']['title'] = $show_fields['billing']['title'];
1115
+ }
1116
+
1117
+ if(isset($billing))
1118
+ $_show_fields['billing'] = $billing;
1119
+
1120
+ if(!isset($show_fields['shipping']['title'])) {
1121
+ $_show_fields['shipping']['title'] = $show_fields['shipping']['title'];
1122
+ }
1123
+
1124
+ if(isset($shipping))
1125
+ $_show_fields['shipping'] = $shipping;
1126
+
1127
+
1128
+ if(isset($show_fields['order']) && !(@is_array($show_fields['order']['fields']))) {
1129
+ $_show_fields['order']['title'] = 'Дополнительные поля';
1130
+ }
1131
+ if(isset($orders))
1132
+ $_show_fields['order'] = $orders;
1133
+ if (isset($_show_fields)) {
1134
+ return $_show_fields;
1135
+ }
1136
+
1137
+ }
1138
+ function woocommerce_save_customer_meta_fields_saphali( $user_id ) {
1139
+ if ( ! current_user_can( 'manage_woocommerce' ) )
1140
+ return $columns;
1141
+
1142
+ $show_fields = $this->woocommerce_get_customer_meta_fields_saphali();
1143
+ if(!empty($show_fields["billing"])) {
1144
+ $save_fields["billing"]['title'] = __('Customer Billing Address', 'woocommerce');
1145
+ $save_fields["billing"]['fields'] = $show_fields["billing"];
1146
+ }
1147
+ if(!empty($show_fields["shipping"])) {
1148
+ $save_fields["shipping"]['title'] = __('Customer Shipping Address', 'woocommerce');
1149
+ $save_fields["shipping"]['fields'] = $show_fields["shipping"];
1150
+ }
1151
+ /* if(!empty($show_fields["order"])) {
1152
+ $save_fields["order"]['title'] = __('Дополнительные поля', 'woocommerce');
1153
+ $save_fields["order"]['fields'] = $show_fields["order"];
1154
+ } */
1155
+ if(isset($save_fields) && is_array($save_fields))
1156
+ foreach( $save_fields as $fieldset )
1157
+ foreach( $fieldset['fields'] as $key => $field )
1158
+ if ( isset( $_POST[ $key ] ) )
1159
+ update_user_meta( $user_id, $key, trim( esc_attr( $_POST[ $key ] ) ) );
1160
+ }
1161
+ function woocommerce_admin_order_data_after_billing_address_s($order) {
1162
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1163
+
1164
+ echo '<div class="address">';
1165
+ if(is_array($billing_data["billing"])) {
1166
+ foreach ( $billing_data["billing"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1167
+
1168
+ $field_name = '_'.$key;
1169
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1170
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1171
+ else
1172
+ $value_fild = $order->__get( $key );
1173
+ if ( $value_fild && !empty($field['label']) ) echo '<p><strong>'.$field['label'].':</strong> '.$value_fild.'</p>';
1174
+
1175
+ endforeach;
1176
+ }
1177
+ echo '</div>';
1178
+ }
1179
+ function woocommerce_admin_order_data_after_shipping_address_s($order) {
1180
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1181
+ echo '<div class="address">';
1182
+ if(is_array($billing_data["shipping"])) {
1183
+ foreach ( $billing_data["shipping"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1184
+
1185
+ $field_name = '_'.$key;
1186
+
1187
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1188
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1189
+ else
1190
+ $value_fild = $order->__get( $key );
1191
+ if ( $value_fild && !empty($field['label']) ) echo '<p><strong>'.$field['label'].':</strong> '.$value_fild.'</p>';
1192
+
1193
+ endforeach;
1194
+ }
1195
+ echo '</div>';
1196
+ }
1197
+ function woocommerce_admin_order_data_after_order_details_s($order) {
1198
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1199
+ echo '<div class="address">';
1200
+ if(is_array($billing_data["order"])) {
1201
+ foreach ( $billing_data["order"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1202
+
1203
+ $field_name = '_'.$key;
1204
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1205
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1206
+ else
1207
+ $value_fild = $order->__get( $key );
1208
+ if ( $value_fild && !empty($field['label']) )
1209
+
1210
+ echo '<div class="form-field form-field-wide"><label>'. $field['label']. ':</label> ' . $value_fild.'</div>';
1211
+
1212
+ endforeach;
1213
+ }
1214
+ echo '</div>';
1215
+
1216
+ }
1217
+ function saphali_custom_override_checkout_fields( $fields ) {
1218
+
1219
+ $fieldss = get_option('woocommerce_saphali_filds_filters');
1220
+ if(is_array($fieldss)) {
1221
+ $fields["billing"] = $fieldss["billing"];
1222
+ $fields["shipping"] = $fieldss["shipping"];
1223
+ $fields["order"] = $fieldss["order"];
1224
+ }
1225
+ foreach(array("billing", "shipping", "order") as $v)
1226
+ foreach($fields[$v] as $key => $value) {
1227
+ if(isset($fields[$v][$key]["label"]))
1228
+ $fields[$v][$key]["label"] = __($value["label"], 'woocommerce');
1229
+ if(isset($fields[$v][$key]["placeholder"]))
1230
+ $fields[$v][$key]["placeholder"] = __($value["placeholder"], 'saphali-woocommerce-lite');
1231
+ }
1232
+ return $fields;
1233
+ }
1234
+ function saphali_custom_edit_address_fields( $fields ) {
1235
+ global $wp;
1236
+ $fieldss = get_option('woocommerce_saphali_filds_filters');
1237
+ if(is_array($fieldss))
1238
+ $_fields = $fieldss["billing"];
1239
+ if( isset($_fields) && is_array($_fields) )
1240
+ foreach($_fields as $key => $value) {
1241
+ if(str_replace( 'billing_','', $key ) != 'email')
1242
+ $__fields[wc_edit_address_i18n( sanitize_key( $wp->query_vars['edit-address'] ), true ) . '_' . str_replace( 'billing_','', $key ) ] = $value;
1243
+ }
1244
+ $_a_ = array_diff($__fields, $fields);
1245
+ if(is_array($_a_) && is_array($fields) ) $fields = (array)$fields + (array)$_a_;
1246
+
1247
+ foreach($fields as $key => $value) {
1248
+ if(isset($fields[$key]["label"]))
1249
+ $fields[$key]["label"] = __($value["label"], 'woocommerce');
1250
+ if(isset($fields[$key]["placeholder"]))
1251
+ $fields[$key]["placeholder"] = __($value["placeholder"], 'woocommerce');
1252
+ }
1253
+ return $fields;
1254
+ }
1255
+ function saphali_custom_billing_fields( $fields ) {
1256
+
1257
+ $fieldss = get_option('woocommerce_saphali_filds_filters');
1258
+ if(is_array($fieldss))
1259
+ $fields = $fieldss["billing"];
1260
+ foreach($fields as $key => $value) {
1261
+ if(isset($fields[$key]["label"]))
1262
+ $fields[$key]["label"] = __($value["label"], 'woocommerce');
1263
+ if(isset($fields[$key]["placeholder"]))
1264
+ $fields[$key]["placeholder"] = __($value["placeholder"], 'woocommerce');
1265
+
1266
+ }
1267
+ return $fields;
1268
+ }
1269
+ function saphali_custom_shipping_fields( $fields ) {
1270
+ $fieldss = get_option('woocommerce_saphali_filds_filters');
1271
+ if(is_array($fieldss))
1272
+ $fields = $fieldss["shipping"];
1273
+ foreach($fields as $key => $value) {
1274
+ if(isset($fields[$key]["label"]))
1275
+ $fields[$key]["label"] = __($value["label"], 'woocommerce');
1276
+ if(isset($fields[$key]["placeholder"]))
1277
+ $fields[$key]["placeholder"] = __($value["placeholder"], 'woocommerce');
1278
+ }
1279
+ return $fields;
1280
+ }
1281
+ public function store_order_id( $arg ) {
1282
+ if ( is_int( $arg ) ) $this->email_order_id = $arg;
1283
+ elseif ( is_array( $arg ) && array_key_exists( 'order_id', $arg ) ) $this->email_order_id = $arg['order_id'];
1284
+ }
1285
+ public function email_pickup_location( $template_name, $template_path, $located ) {
1286
+ global $_shipping_data, $_billing_data;
1287
+ if ( $template_name == 'emails/email-addresses.php' && $this->email_order_id ) {
1288
+
1289
+ $order = new WC_Order( $this->email_order_id );
1290
+
1291
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1292
+ echo '<div class="address">';
1293
+
1294
+ if(is_array($billing_data["billing"]) && !$_billing_data) {
1295
+ foreach ( $billing_data["billing"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1296
+ $field_name = '_'.$key;
1297
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1298
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1299
+ else
1300
+ $value_fild = $order->__get( $key );
1301
+ if ( $value_fild && !empty($field['label']) )
1302
+ echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1303
+ endforeach;
1304
+ }
1305
+ if(is_array($billing_data["shipping"]) && !$_shipping_data) {
1306
+ foreach ( $billing_data["shipping"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1307
+ $field_name = '_'.$key;
1308
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1309
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1310
+ else
1311
+ $value_fild = $order->__get( $key );
1312
+ if ( $value_fild && !empty($field['label']))
1313
+ echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1314
+ endforeach;
1315
+ }
1316
+ if(is_array($billing_data["order"])) {
1317
+ foreach ( $billing_data["order"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1318
+
1319
+ $field_name = '_'.$key;
1320
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1321
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1322
+ else
1323
+ $value_fild = $order->__get( $key );
1324
+ if ( $value_fild && !empty($field['label']) )
1325
+
1326
+ echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1327
+
1328
+ endforeach;
1329
+ }
1330
+ echo '</div>';
1331
+ }
1332
+ }
1333
+ /* function formatted_billing_address($address, $order) {
1334
+ global $billing_data, $_billing_data;
1335
+ if( empty($billing_data) )
1336
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1337
+ if(is_array($billing_data["billing"])) {
1338
+ $_billing_data = true;
1339
+ $no_fild = array ('_billing_booking_delivery_t', '_billing_booking_delivery');
1340
+ foreach ( $billing_data["billing"] as $key => $field ) : if (isset($field['show']) && !$field['show'] ) continue;
1341
+
1342
+ $field_name = '_'.$key;
1343
+
1344
+ if(in_array($field_name, $no_fild)) continue;
1345
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1346
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1347
+ else
1348
+ $value_fild = $order->__get( $key );
1349
+ if ( $value_fild && !empty($field['label']))
1350
+ echo '<label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'<br />';
1351
+ endforeach;
1352
+ }
1353
+ return $address;
1354
+ }
1355
+ function formatted_shipping_address($address, $order) {
1356
+ global $billing_data, $_shipping_data;
1357
+ if( empty($billing_data) )
1358
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1359
+ if(is_array($billing_data["shipping"])) {
1360
+ $_shipping_data = true;
1361
+ foreach ( $billing_data["shipping"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1362
+ $field_name = '_'.$key;
1363
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1364
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1365
+ else
1366
+ $value_fild = $order->__get( $key );
1367
+ if ( $value_fild && !empty($field['label'])) {
1368
+ echo '<label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'<br />';
1369
+ $address[$key] = $value_fild;
1370
+ }
1371
+ endforeach;
1372
+ }
1373
+ return $address;
1374
+ }*/
1375
+ function order_pickup_location($order_id) {
1376
+ global $_billing_data, $_shipping_data;
1377
+ $order = new WC_Order( $order_id );
1378
+
1379
+ if ( is_object($order) ) {
1380
+
1381
+ $billing_data = $this->woocommerce_get_customer_meta_fields_saphali();
1382
+
1383
+ echo '<div class="address">';
1384
+
1385
+ if(is_array($billing_data["billing"]) && !$_billing_data) {
1386
+ foreach ( $billing_data["billing"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1387
+ $field_name = '_'.$key;
1388
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1389
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1390
+ else
1391
+ $value_fild = $order->__get( $key );
1392
+ if ( $value_fild && !empty($field['label']))
1393
+ echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1394
+ endforeach;
1395
+ }
1396
+ if(is_array($billing_data["shipping"]) && !$_shipping_data) {
1397
+ foreach ( $billing_data["shipping"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1398
+ $field_name = '_'.$key;
1399
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1400
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1401
+ else
1402
+ $value_fild = $order->__get( $key );
1403
+ if ( $value_fild && !empty($field['label']) )
1404
+ echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1405
+ endforeach;
1406
+ }
1407
+ if(is_array($billing_data["order"]) ) {
1408
+ foreach ( $billing_data["order"] as $key => $field ) : if (isset($field['show']) && !$field['show']) continue;
1409
+ $field_name = '_'.$key;
1410
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) )
1411
+ $value_fild = @$order->order_custom_fields[$field_name][0];
1412
+ else
1413
+ $value_fild = $order->__get( $key );
1414
+ if ( $value_fild && !empty($field['label']) )
1415
+ echo '<div class="form-field form-field-wide"><label><strong>'. $field['label']. ':</strong></label> ' . $value_fild.'</div>';
1416
+ endforeach;
1417
+ }
1418
+ echo '</div>';
1419
+ }
1420
+ }
1421
+ function print_columns ($columns) {
1422
+ return $this->column_count_saphali;
1423
+ }
1424
+ function related_print_columns ($columns) {
1425
+ if( isset($columns['columns']) ) {
1426
+ $columns['columns'] = $this->column_count_saphali;
1427
+ $columns['posts_per_page'] = $this->column_count_saphali;
1428
+ }
1429
+
1430
+ return $columns;
1431
+ }
1432
+ function print_script_columns($woocommerce_loop) {
1433
+ global $woocommerce_loop;
1434
+ if($woocommerce_loop['columns'] > 0 && $woocommerce_loop['columns'] != 4) {
1435
+ ?>
1436
+ <style type='text/css'>
1437
+ .woocommerce ul.products li.product {
1438
+ width:<?php if($woocommerce_loop['columns'] <= 3 ) echo floor(100/$woocommerce_loop['columns'] - $woocommerce_loop['columns']); elseif($woocommerce_loop['columns'] > 3 )echo floor(100/$woocommerce_loop['columns'] - 4);?>%;
1439
+ }
1440
+ </style>
1441
+ <?php
1442
+ }
1443
+ }
1444
+ }
1445
+
1446
+ add_action('plugins_loaded', 'woocommerce_lang_s_l', 0);
1447
+ if ( ! function_exists( 'woocommerce_lang_s_l' ) ) {
1448
+ function woocommerce_lang_s_l() {
1449
+ $lite = new saphali_lite();
1450
+ if( is_admin() )
1451
+ add_action( 'admin_enqueue_scripts', array( $lite, 'admin_enqueue_scripts_page_saphali' ) );
1452
+ }
1453
+ }
1454
+ //END
1455
+ add_action("wp_head", '_print_script_columns', 10 );
1456
+ add_action("admin_head", '_print_script_columns', 10);
1457
+ function _print_script_columns() {
1458
+ if(apply_filters( 'woocommerce_currency', get_option('woocommerce_currency') ) != 'RUB' || !(version_compare( WOOCOMMERCE_VERSION, '2.5.2', '<' ) || SAPHALI_LITE_SYMBOL ) ) return;
1459
+ ?>
1460
+ <style type="text/css">
1461
+ /* @font-face { font-family: "Rubl Sign"; src: url(<?php echo SAPHALI_PLUGIN_DIR_URL; ?>ruble.eot); } */
1462
+
1463
+ @font-face { font-family: "rub-arial-regular"; src: url("<?php echo SAPHALI_PLUGIN_DIR_URL; ?>ruble-simb.woff"), url("<?php echo SAPHALI_PLUGIN_DIR_URL; ?>ruble-simb.ttf");
1464
+ }
1465
+ span.rur {
1466
+ font-family: rub-arial-regular;
1467
+ text-transform: uppercase;
1468
+ }
1469
+ span.rur span { display: none; }
1470
+
1471
+ /* span.rur { font-family: "Rubl Sign"; text-transform: uppercase;}
1472
+ span.rur:before {top: 0.06em;left: 0.55em;content: '\2013'; position: relative;} */
1473
+ </style>
1474
+ <?php
1475
+ }
1476
+
1477
+
1478
+ register_activation_hook( __FILE__, 'saphali_woo_lite_install' );
1479
+
1480
+ function saphali_woo_lite_install() {
1481
+ $filds_finish_filter = get_option('woocommerce_saphali_filds_filters');
1482
+ if($filds_finish_filter) {
1483
+ foreach($filds_finish_filter['billing'] as $k_f => $v_f) {
1484
+ $new_key = str_replace('billing_', '' , $k_f);
1485
+ if(in_array($new_key, array('country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ) )) {
1486
+ $locate[$new_key] = $v_f;
1487
+ if( isset($locate[$new_key]['clear']) && $locate[$new_key]['clear'] == 'on') $locate[$new_key]['clear'] = true;
1488
+ if( isset($locate[$new_key]['required']) && $locate[$new_key]['required'] == 'on') $locate[$new_key]['required'] = true;
1489
+ } elseif(in_array(str_replace('shipping_', '' , $k_f), array('country', 'first_name', 'last_name', 'company', 'address_1', 'address_2', 'city', 'state', 'postcode' ) )) {
1490
+ $locate[$new_key] = $filds_finish_filter['shipping'][$k_f];
1491
+ if( isset($locate[$new_key]['clear']) && $locate[$new_key]['clear'] == 'on') $locate[$new_key]['clear'] = true;
1492
+ if( isset($locate[$new_key]['required']) && $locate[$new_key]['required'] == 'on') $locate[$new_key]['required'] = true;
1493
+ }
1494
+
1495
+ }
1496
+ update_option('woocommerce_saphali_filds_locate',$locate);
1497
+ }
1498
+ //if(!update_option('woocommerce_informal_localisation_type' , 'yes'))add_option('woocommerce_informal_localisation_type' , 'yes');
1499
+ //global $woocommerce;
1500
+ //copy( SAPHALI_PLUGIN_DIR_PATH . '/languages/woocommerce-ru_RU.mo', $woocommerce->plugin_path() .'/i18n/languages/informal/woocommerce-ru_RU.mo');
1501
+ //copy( SAPHALI_PLUGIN_DIR_PATH . '/languages/woocommerce-ru_RU.po', $woocommerce->plugin_path() .'/i18n/languages/informal/woocommerce-ru_RU.po');
1502
  }