WooCommerce Checkout Manager - Version 3.6.6

Version Description

GUI + Code clean up. Multi-lang Save issue fix.

Download this release

Release Info

Developer Emark
Plugin Icon 128x128 WooCommerce Checkout Manager
Version 3.6.6
Comparing to
See all releases

Code changes from version 3.6.5 to 3.6.6

Files changed (3) hide show
  1. readme.txt +6 -122
  2. style_wccs.css +89 -0
  3. woocommerce-checkout-manager.php +824 -1090
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Emark
3
  Donate link: http://www.trottyzone.com/donation/
4
  Tags: woocommerce, checkout settings, remove fields, shipping, order, fields, checkout page, checkout field, checkout manager, required remove, woocommerce checkout manager, checkout, checkout field editor, field editor, woocommerce custom checkout options , custom checkout, checkout option, field, payment, sell, buy, pay, tax, notice, re-order, order, new field, save field, manager, options, field editor
5
  Requires at least: 3.0
6
- Tested up to: 4.0
7
- Stable tag: 3.6.5
8
  License: GPLv2 or later
9
 
10
  Manages WooCommerce Checkout
@@ -183,8 +183,7 @@ Should you have any questions or concerns please contact at the <a href="http://
183
 
184
  7. SELECT OPTIONS
185
 
186
-
187
- == Upgrade Notice ==
188
  = 1.0 =
189
  Initial
190
 
@@ -303,121 +302,6 @@ WPML bug fixes 3
303
  = 3.6.5 =
304
  WPML bug fixes 4
305
 
306
- == Changelog ==
307
- = 1.0 =
308
- Initial
309
-
310
- = 1.2 =
311
- Added required attribute removal
312
-
313
- = 1.3 =
314
- bug fix!
315
-
316
- = 1.4 =
317
- More features added.
318
-
319
- = 1.5 =
320
- some bugs fixed
321
-
322
- = 1.6 =
323
- more bugs fixed
324
-
325
- = 1.7 =
326
- add/remove required field for each new fields
327
-
328
- = 2.0 =
329
- Custom fields data are added to the receipt
330
-
331
- = 2.1 =
332
- Checkout process fix
333
-
334
- = 2.2 =
335
- bug fix
336
-
337
- = 2.3 =
338
- Additional features
339
-
340
- = 2.4 =
341
- Localization Ready
342
-
343
- = 2.5 =
344
- Added features for shipping
345
-
346
- = 2.6 =
347
- remove fields for shipping
348
-
349
- = 2.7 =
350
- required attribute bug fix and included translations
351
-
352
- = 2.8 =
353
- Bug fixes
354
-
355
- = 2.9 =
356
- Bug fixes
357
-
358
- = 3.0 =
359
- Javascript fix and rename fields inserted
360
-
361
- = 3.1 =
362
- bug fix
363
-
364
- = 3.2 =
365
- code review
366
-
367
- = 3.3 =
368
- fields positioning, fixed.
369
-
370
- = 3.4 =
371
- bug fixed.
372
-
373
- = 3.5 =
374
- Select date function, included.
375
-
376
- = 3.5.1 =
377
- Select option and checkbox functions, included.
378
-
379
- = 3.5.2 =
380
- updating to standard.
381
-
382
- = 3.5.3 =
383
- bug fix- force selection for option and minor fix.
384
-
385
- = 3.5.4 =
386
- Added feature.
387
-
388
- = 3.5.5 =
389
- Translations updated
390
-
391
- = 3.5.6 =
392
- Included translations - Vietnamse, Italian, European Portuguese, Brazilian Portuguese
393
- Layout fixed on Order Summary Page
394
-
395
- = 3.5.7 =
396
- Bug fix.
397
-
398
- = 3.5.8 =
399
- Bug fix.
400
-
401
- = 3.5.81 =
402
- Bulgarian language by Ivo Minchev
403
-
404
- = 3.5.9 =
405
- Bug fix.
406
-
407
- = 3.6 =
408
- Bug fixes.
409
-
410
- = 3.6.1 =
411
- Compatibility with 2.1.7 WooCommerce && WPML
412
-
413
- = 3.6.2 =
414
- WPML bug fix
415
-
416
- = 3.6.3 =
417
- WPML bug fix 2 (translation for e-mails)
418
-
419
- = 3.6.4 =
420
- WPML bug fixes 3
421
-
422
- = 3.6.5 =
423
- WPML bug fixes 4
3
  Donate link: http://www.trottyzone.com/donation/
4
  Tags: woocommerce, checkout settings, remove fields, shipping, order, fields, checkout page, checkout field, checkout manager, required remove, woocommerce checkout manager, checkout, checkout field editor, field editor, woocommerce custom checkout options , custom checkout, checkout option, field, payment, sell, buy, pay, tax, notice, re-order, order, new field, save field, manager, options, field editor
5
  Requires at least: 3.0
6
+ Tested up to: 4.2
7
+ Stable tag: 3.6.6
8
  License: GPLv2 or later
9
 
10
  Manages WooCommerce Checkout
183
 
184
  7. SELECT OPTIONS
185
 
186
+ == Changelog ==
 
187
  = 1.0 =
188
  Initial
189
 
302
  = 3.6.5 =
303
  WPML bug fixes 4
304
 
305
+ = 3.6.6 =
306
+ GUI + Code clean up.
307
+ Multi-lang Save issue fix.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
style_wccs.css ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wooccm_title {
2
+ margin: 5px 0 15px 10px;
3
+ color: #fff;
4
+ font-size: 18px;
5
+ float: left;
6
+ background: #0074a2;
7
+ padding: 15px 20px;
8
+ border-radius: 5px;
9
+ margin-left: 0px;
10
+ }
11
+ input[type="text"] {
12
+ width: 100%;
13
+ }
14
+ .small {
15
+ font-size: 10px;
16
+ }
17
+ .wooccm_feed {
18
+ float: right;
19
+ margin-right: 10px;
20
+ font-size: 14px;
21
+ }
22
+ .wccs-clone {
23
+ display:none;
24
+ }
25
+ .clear_wccm {
26
+ float: left;
27
+ }
28
+ p.submit {
29
+ float: right;
30
+ padding: 0 !IMPORTANT;
31
+ margin: 0 !IMPORTANT;
32
+ }
33
+ .clear_wccm.title {
34
+ margin-top: 30px;
35
+ margin-right: 12px;
36
+ margin-left: 12px;
37
+ width: 14%;
38
+ }
39
+ .clear_wccm.data {
40
+ width: 97%;
41
+ }
42
+ .clear_wccm ul {
43
+ float: left;
44
+ padding: 0 32px;
45
+ list-style: square;
46
+ }
47
+ .widefat input {
48
+ float: right;
49
+ }
50
+ .wccs_replace {
51
+ width: 20%;
52
+ }
53
+ .wccs-order {
54
+ cursor:move;
55
+ }
56
+ .wccs-table > tbody > tr > td {
57
+ background: #fff;
58
+ border-right: 1px solid #ededed;
59
+ border-bottom: 1px solid #ededed;
60
+ padding: 8px;
61
+ position: relative;
62
+ }
63
+ .wccs-table > tbody > tr:last-child td { border-bottom: 0 none; }
64
+ .wccs-table > tbody > tr td:last-child { border-right: 0 none; }
65
+ .wccs-table > thead > tr > th { border-right: 1px solid #e1e1e1; }
66
+ .wccs-table > thead > tr > th:last-child { border-right: 0 none; }
67
+ .wccs-table tr td.wccs-order,
68
+ .wccs-table tr th.wccs-order {
69
+ width: 16px;
70
+ text-align: center;
71
+ vertical-align: middle;
72
+ color: #aaa;
73
+ text-shadow: #fff 0 1px 0;
74
+ }
75
+ .wccs-table .wccs-remove {
76
+ font-size: 20px;
77
+ font-weight: 700;
78
+ vertical-align: middle;
79
+ text-align: center;
80
+ }
81
+ .wccs-table input[type="text"] {
82
+ width: 100%;
83
+ }
84
+ .wccs-table-footer {
85
+ position: relative;
86
+ overflow: hidden;
87
+ margin-top: 10px;
88
+ padding: 8px 0;
89
+ }
woocommerce-checkout-manager.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WooCommerce Checkout Manager
4
  Plugin URI: http://www.trottyzone.com/product/woocommerce-checkout-manager-pro
5
  Description: Manages WooCommerce Checkout fields
6
- Version: 3.6.5
7
  Author: Ephrain Marchan
8
  Author URI: http://www.trottyzone.com
9
  License: GPLv2 or later
@@ -21,1218 +21,952 @@ You should have received a copy of the GNU General Public License
21
  along with this program; if not, write to the Free Software
22
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
  */
24
- if ( ! defined( 'ABSPATH' ) ) die();
25
- register_activation_hook( __FILE__, 'wccs_install' );
 
26
  load_plugin_textdomain('woocommerce-checkout-manager', false, dirname(plugin_basename(__FILE__)) . '/languages/');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  function wccs_install() {
28
- $defaults = array( 'buttons' => array( array(
29
- 'label' => __( 'Example Label', 'woocommerce-checkout-manager' ),
30
- 'placeholder' => __( 'Example placeholder', 'woocommerce-checkout-manager' ),
31
- 'cow' => __('myfld1', 'woocommerce-checkout-manager'),
32
- 'option_a' => __('option 1', 'woocommerce-checkout-manager'),
33
- 'option_b' => __('option 2', 'woocommerce-checkout-manager')
34
- )
35
- ),
36
- 'checkness' => array(
37
- 'checkbox1' => true,
38
- 'checkbox12' => true
39
- )
40
- );
 
 
 
41
  add_option( 'wccs_settings', apply_filters( 'wccs_defaults', $defaults ) );
42
  }
43
- // Hook for adding admin menus
44
- if ( is_admin() ){ // admin actions
45
- // Hook for adding admin menu
46
- add_action( 'admin_menu', 'wccs_admin_menu' );
47
- // Display the 'Settings' link in the plugin row on the installed plugins list page
48
- add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'wccs_admin_plugin_actions', -10);
49
- add_action( 'admin_init', 'wccs_register_setting' );
50
- } else { // non-admin enqueues, actions, and filters
51
- // hook to get option values and dynamically render css to support the tab classes
52
- wp_enqueue_script('jquery-ui-datepicker');
53
- wp_enqueue_style( 'jquery-ui-style', (is_ssl()) ? 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' : 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
54
- }
55
- // action function for above hook
 
 
 
 
 
 
56
  function wccs_admin_menu() {
57
- // Add a new submenu under Settings:
58
- add_options_page( __('WooCommerce Checkout Manager', 'woocommerce-checkout-manager'), __('WooCommerce Checkout Manager', 'woocommerce-checkout-manager'), 'manage_options', __FILE__ , 'wccs__options_page');
59
  }
 
 
60
  function wccs_register_setting() {
61
- register_setting( 'wccs_options', 'wccs_settings', 'wccs_options_validate' );
62
  }
63
- // fc_settings_page() displays the page content
 
64
  function wccs__options_page() {
65
- //must check that the user has the required capability
66
- if (!current_user_can('manage_options'))
67
- {
68
- wp_die( __('You do not have sufficient permissions to access this page.') );
69
  }
70
- // variables for the field and option names
71
- $hidden_field_name = 'mccs_submit_hidden';
72
- // read options values
73
  $options = get_option( 'wccs_settings' );
74
- if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) {
75
- // Save the posted value in the database
76
- update_option( 'wccs_settings', $options );
77
- ?>
78
- <div class="updated"><p><strong><?php _e('settings saved.'); ?></strong></p></div>
79
- <?php
 
80
  }
81
- // Now display the settings editing screen
82
  echo '<div class="wrap">';
83
- // icon for settings
84
  echo '<div id="icon-themes" class="icon32"><br></div>';
85
- // header
86
- echo "<h2>" . __( 'WooCommerce Checkout Manager', 'woocommerce-checkout-manager' ) . "";
87
- // settings form
88
  ?>
89
- <!-- FEED -->
 
90
  <div class="wooccm_feed">
91
- <?php // Get RSS Feed(s)
92
- include_once( ABSPATH . WPINC . '/feed.php' );
93
 
94
- // Get a SimplePie feed object from the specified feed source.
95
- $rss = fetch_feed( 'http://www.trottyzone.com/category/news-feed/' );
96
 
97
- if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
 
 
 
 
98
 
99
- // Figure out how many total items there are, but limit it to 5.
100
- $maxitems = $rss->get_item_quantity( 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
- // Build an array of all the items, starting with element 0 (first element).
103
- $rss_items = $rss->get_items( 0, $maxitems );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
- endif;
106
- ?>
107
- <?php if ( $maxitems == 0 ) : ?>
108
- <?php else : ?>
109
- <?php // Loop through each feed item and display each item as a hyperlink. ?>
110
- <?php foreach ( $rss_items as $item ) : ?>
111
-
112
- <a href="<?php echo esc_url( $item->get_permalink() ); ?>"
113
- title="<?php printf( __( 'Posted %s', 'woocommerce-checkout-manager' ), $item->get_date('j F Y | g:i a') ); ?>">
114
- <?php echo esc_html( $item->get_title() ); ?>
115
- </a>
116
-
117
- <?php endforeach; ?>
118
- <?php endif; ?>
119
-
120
- </div></h2>
121
- <!-- FEED -->
122
- <form name="form" method="post" action="options.php" id="frm1">
123
- <?php
124
- settings_fields( 'wccs_options' );
125
- $options = get_option( 'wccs_settings' );
126
- ?>
127
- <table class="widefat" border="1" >
128
- <thead>
129
- <tr>
130
- <th><?php _e('Field Name', 'woocommerce-checkout-manager'); ?></th>
131
- <th><?php _e('Remove Field Entirely', 'woocommerce-checkout-manager'); ?></th>
132
- <th><?php _e('Remove Required Attribute', 'woocommerce-checkout-manager'); ?></th>
133
- <th class="wccs_replace"><?php _e('Replace Label Name', 'woocommerce-checkout-manager'); ?></th>
134
- <th class="wccs_replace"><?php _e('Replace Placeholder Name', 'woocommerce-checkout-manager'); ?></th>
135
- </tr>
136
- </thead>
137
- <tbody>
138
- <tr>
139
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
140
- <td><strong><?php _e('Select All Check boxes in this Column', 'woocommerce-checkout-manager'); ?></strong></td>
141
- <td><input name="wccs_settings[checkness][select_all_rm]" type="checkbox" id="select_all_rm" value="1" <?php echo (isset($options['checkness']['select_all_rm'])) ? "checked='checked'" : ""; ?> /></td>
142
- <td><input name="wccs_settings[checkness][select_all_rq]" type="checkbox" id="select_all_rq" value="1" <?php echo (isset($options['checkness']['select_all_rq'])) ? "checked='checked'" : ""; ?> /></td>
143
- <td></td>
144
- <td></td>
145
- </tr>
146
- </tbody>
147
- <tbody>
148
- <tr>
149
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
150
- <td><?php _e('First Name', 'woocommerce-checkout-manager'); ?></td>
151
- <td><input name="wccs_settings[checkness][wccs_opt_1]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_1'])) ? "checked='checked'" : ""; ?> /></td>
152
-
153
- <td><input name="wccs_settings[checkness][wccs_rq_1]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_1'])) ? "checked='checked'" : ""; ?> /></td>
154
-
155
-
156
- <td><input type="text" name="wccs_settings[replace][label]"
157
- value="<?php echo esc_attr( $options['replace']['label'] ); ?>" /></td>
158
- <td><input type="text" name="wccs_settings[replace][placeholder]"
159
- value="<?php echo esc_attr( $options['replace']['placeholder'] ); ?>" /></td>
160
- </tr>
161
- </tbody>
162
- <tbody>
163
- <tr>
164
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
165
- <td><?php _e('Last Name', 'woocommerce-checkout-manager'); ?></td>
166
- <td><input name="wccs_settings[checkness][wccs_opt_2]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_2'])) ? "checked='checked'" : ""; ?> /></td>
167
- <td><input name="wccs_settings[checkness][wccs_rq_2]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_2'])) ? "checked='checked'" : ""; ?> /></td>
168
- <td><input type="text" name="wccs_settings[replace][label1]"
169
- value="<?php echo esc_attr( $options['replace']['label1'] ); ?>" /></td>
170
- <td><input type="text" name="wccs_settings[replace][placeholder1]"
171
- value="<?php echo esc_attr( $options['replace']['placeholder1'] ); ?>" /></td>
172
- </tr>
173
- </tbody>
174
- <tbody>
175
- <tr>
176
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
177
- <td><?php _e('Country', 'woocommerce-checkout-manager'); ?></td>
178
- <td><input name="wccs_settings[checkness][wccs_opt_8]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_8'])) ? "checked='checked'" : ""; ?> /></td>
179
- <td><input name="wccs_settings[checkness][wccs_rq_8]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_8'])) ? "checked='checked'" : ""; ?> /></td>
180
- <td><input type="text" name="wccs_settings[replace][label2]"
181
- value="<?php echo esc_attr( $options['replace']['label2'] ); ?>" /></td>
182
- <td></td>
183
- </tr>
184
- </tbody>
185
- <tbody>
186
- <tr>
187
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
188
- <td><?php _e('Phone', 'woocommerce-checkout-manager'); ?></td>
189
- <td><input name="wccs_settings[checkness][wccs_opt_10]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_10'])) ? "checked='checked'" : ""; ?> /></td>
190
- <td><input name="wccs_settings[checkness][wccs_rq_10]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_10'])) ? "checked='checked'" : ""; ?> /></td>
191
- <td><input type="text" name="wccs_settings[replace][label3]"
192
- value="<?php echo esc_attr( $options['replace']['label3'] ); ?>" /></td>
193
- <td><input type="text" name="wccs_settings[replace][placeholder3]"
194
- value="<?php echo esc_attr( $options['replace']['placeholder3'] ); ?>" /></td>
195
- </tr>
196
- </tbody>
197
- <tbody>
198
- <tr>
199
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
200
- <td><?php _e('Email', 'woocommerce-checkout-manager'); ?></td>
201
- <td><input name="wccs_settings[checkness][wccs_opt_11]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_11'])) ? "checked='checked'" : ""; ?> /></td>
202
- <td><input name="wccs_settings[checkness][wccs_rq_11]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_11'])) ? "checked='checked'" : ""; ?> /></td>
203
- <td><input type="text" name="wccs_settings[replace][label4]"
204
- value="<?php echo esc_attr( $options['replace']['label4'] ); ?>" /></td>
205
- <td><input type="text" name="wccs_settings[replace][placeholder4]"
206
- value="<?php echo esc_attr( $options['replace']['placeholder4'] ); ?>" /></td>
207
- </tr>
208
- </tbody>
209
- <tbody>
210
- <tr>
211
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
212
- <td><?php _e('Company', 'woocommerce-checkout-manager'); ?></td>
213
- <td><input name="wccs_settings[checkness][wccs_opt_3]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_3'])) ? "checked='checked'" : ""; ?> /></td>
214
- <td></td>
215
- <td><input type="text" name="wccs_settings[replace][label5]"
216
- value="<?php echo esc_attr( $options['replace']['label5'] ); ?>" /></td>
217
- <td><input type="text" name="wccs_settings[replace][placeholder5]"
218
- value="<?php echo esc_attr( $options['replace']['placeholder5'] ); ?>" /></td>
219
- </tr>
220
- </tbody>
221
- <tbody>
222
- <tr>
223
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
224
- <td><?php _e('Order Notes', 'woocommerce-checkout-manager'); ?></td>
225
- <td><input name="wccs_settings[checkness][wccs_opt_12]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_12'])) ? "checked='checked'" : ""; ?> /></td>
226
- <td></td>
227
- <td><input type="text" name="wccs_settings[replace][label11]"
228
- value="<?php echo esc_attr( $options['replace']['label11'] ); ?>" /></td>
229
- <td><input type="text" name="wccs_settings[replace][placeholder11]"
230
- value="<?php echo esc_attr( $options['replace']['placeholder11'] ); ?>" /></td>
231
- </tr>
232
- </tbody>
233
- <tbody>
234
- <tr>
235
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
236
- <td><?php _e('Address 1', 'woocommerce-checkout-manager'); ?></td>
237
- <td><input name="wccs_settings[checkness][wccs_opt_4]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_4'])) ? "checked='checked'" : ""; ?></td>
238
- <td></td>
239
- <td></td>
240
- <td></td>
241
- </tr>
242
- </tbody>
243
- <tbody>
244
- <tr>
245
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
246
- <td><?php _e('Address 2', 'woocommerce-checkout-manager'); ?></td>
247
- <td><input name="wccs_settings[checkness][wccs_opt_5]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_5'])) ? "checked='checked'" : ""; ?> /></td>
248
- <td></td>
249
- <td></td>
250
- <td></td>
251
- </tr>
252
- </tbody>
253
- <tbody>
254
- <tr>
255
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
256
- <td><?php _e('City', 'woocommerce-checkout-manager'); ?></td>
257
- <td><input name="wccs_settings[checkness][wccs_opt_6]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_6'])) ? "checked='checked'" : ""; ?> /></td>
258
- <td></td>
259
- <td></td>
260
- <td></td>
261
- </tr>
262
- </tbody>
263
- <tbody>
264
- <tr>
265
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
266
- <td><?php _e('Postal Code', 'woocommerce-checkout-manager'); ?></td>
267
- <td><input name="wccs_settings[checkness][wccs_opt_7]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_7'])) ? "checked='checked'" : ""; ?> /></td>
268
- <td></td>
269
- <td></td>
270
- <td></td>
271
- </tr>
272
- </tbody>
273
- <tbody>
274
- <tr>
275
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
276
- <td><?php _e('State', 'woocommerce-checkout-manager'); ?></td>
277
- <td><input name="wccs_settings[checkness][wccs_opt_9]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_9'])) ? "checked='checked'" : ""; ?> /></td>
278
- <td></td>
279
- <td></td>
280
- <td></td>
281
- </tr>
282
- </tbody>
283
- <?php submit_button( __( 'Save Changes', 'woocommerce-checkout-manager' ) ); ?>
284
- <div style="margin:5px 0 15px 10px;color:green;font-size:18px;float:left;">= <?php _e('Billing Section', 'woocommerce-checkout-manager'); ?> =</div>
285
- </table>
286
- <table class="widefat" border="1" >
287
- <thead>
288
- <tr>
289
- <th><?php _e('Field Name', 'woocommerce-checkout-manager'); ?></th>
290
- <th><?php _e('Remove Field Entirely', 'woocommerce-checkout-manager'); ?></th>
291
- <th><?php _e('Remove Required Attribute', 'woocommerce-checkout-manager'); ?></th>
292
- <th class="wccs_replace"><?php _e('Replace Label Name', 'woocommerce-checkout-manager'); ?></th>
293
- <th class="wccs_replace"><?php _e('Replace Placeholder Name', 'woocommerce-checkout-manager'); ?></th>
294
- </tr>
295
- </thead>
296
- <tbody>
297
- <tr>
298
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
299
- <td><strong><?php _e('Select All Check boxes in this Column', 'woocommerce-checkout-manager'); ?></strong></td>
300
- <td><input name="wccs_settings[check][select_all_rm_s]" type="checkbox" id="select_all_rm_s" value="1" <?php echo (isset($options['check']['select_all_rm_s'])) ? "checked='checked'" : ""; ?> /></td>
301
- <td><input name="wccs_settings[check][select_all_rq_s]" type="checkbox" id="select_all_rq_s" value="1" <?php echo (isset($options['check']['select_all_rq_s'])) ? "checked='checked'" : ""; ?> /></td>
302
- <td></td>
303
- <td></td>
304
- </tr>
305
- </tbody>
306
- <tbody>
307
- <tr>
308
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
309
- <td><?php _e('First Name', 'woocommerce-checkout-manager'); ?></td>
310
- <td><input name="wccs_settings[check][wccs_opt_1_s]" type="checkbox" class="rm_s" value="1"
311
- <?php echo (isset($options['check']['wccs_opt_1_s'])) ? "checked='checked'" : ""; ?> /></td>
312
- <td><input name="wccs_settings[check][wccs_rq_1_s]" type="checkbox" class="rq_s" value="1" <?php echo (isset($options['check']['wccs_rq_1_s'])) ? "checked='checked'" : ""; ?> /></td>
313
- <td><input type="text" name="wccs_settings[replace][label_s]"
314
- value="<?php echo esc_attr( $options['replace']['label_s'] ); ?>" /></td>
315
- <td><input type="text" name="wccs_settings[replace][placeholder_s]"
316
- value="<?php echo esc_attr( $options['replace']['placeholder_s'] ); ?>" /></td>
317
- </tr>
318
- </tbody>
319
- <tbody>
320
- <tr>
321
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
322
- <td><?php _e('Last Name', 'woocommerce-checkout-manager'); ?></td>
323
- <td><input name="wccs_settings[check][wccs_opt_2_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_2_s'])) ? "checked='checked'" : ""; ?> /></td>
324
- <td><input name="wccs_settings[check][wccs_rq_2_s]" type="checkbox" class="rq_s" value="1" <?php echo (isset($options['check']['wccs_rq_2_s'])) ? "checked='checked'" : ""; ?> /></td>
325
- <td><input type="text" name="wccs_settings[replace][label_s1]"
326
- value="<?php echo esc_attr( $options['replace']['label_s1'] ); ?>" /></td>
327
- <td><input type="text" name="wccs_settings[replace][placeholder_s1]"
328
- value="<?php echo esc_attr( $options['replace']['placeholder_s1'] ); ?>" /></td>
329
- </tr>
330
- </tbody>
331
- <tbody>
332
- <tr>
333
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
334
- <td><?php _e('Company', 'woocommerce-checkout-manager'); ?></td>
335
- <td><input name="wccs_settings[check][wccs_opt_3_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_3_s'])) ? "checked='checked'" : ""; ?> /></td>
336
- <td></td>
337
- <td><input type="text" name="wccs_settings[replace][label_s2]"
338
- value="<?php echo esc_attr( $options['replace']['label_s2'] ); ?>" /></td>
339
- <td><input type="text" name="wccs_settings[replace][placeholder_s2]"
340
- value="<?php echo esc_attr( $options['replace']['placeholder_s2'] ); ?>" /></td>
341
- </tr>
342
- </tbody>
343
- <tbody>
344
- <tr>
345
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
346
- <td><?php _e('Country', 'woocommerce-checkout-manager'); ?></td>
347
- <td><input name="wccs_settings[check][wccs_opt_8_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_8_s'])) ? "checked='checked'" : ""; ?> /></td>
348
- <td></td>
349
- <td><input type="text" name="wccs_settings[replace][label_s7]"
350
- value="<?php echo esc_attr( $options['replace']['label_s7'] ); ?>" /></td>
351
- <td></td>
352
- </tr>
353
- </tbody>
354
- <tbody>
355
- <tr>
356
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
357
- <td><?php _e('Address 1', 'woocommerce-checkout-manager'); ?></td>
358
- <td><input name="wccs_settings[check][wccs_opt_4_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_4_s'])) ? "checked='checked'" : ""; ?></td>
359
- <td></td>
360
- <td></td>
361
- <td></td>
362
- </tr>
363
- </tbody>
364
- <tbody>
365
- <tr>
366
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
367
- <td><?php _e('Address 2', 'woocommerce-checkout-manager'); ?></td>
368
- <td><input name="wccs_settings[check][wccs_opt_5_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_5_s'])) ? "checked='checked'" : ""; ?> /></td>
369
- <td></td>
370
- <td></td>
371
- <td></td>
372
- </tr>
373
- </tbody>
374
- <tbody>
375
- <tr>
376
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
377
- <td><?php _e('City', 'woocommerce-checkout-manager'); ?></td>
378
- <td><input name="wccs_settings[check][wccs_opt_6_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_6_s'])) ? "checked='checked'" : ""; ?> /></td>
379
- <td></td>
380
- <td></td>
381
- <td></td>
382
- </tr>
383
- </tbody>
384
- <tbody>
385
- <tr>
386
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
387
- <td><?php _e('Postal Code', 'woocommerce-checkout-manager'); ?></td>
388
- <td><input name="wccs_settings[check][wccs_opt_7_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_7_s'])) ? "checked='checked'" : ""; ?> /></td>
389
- <td></td>
390
- <td></td>
391
- <td></td>
392
- </tr>
393
- </tbody>
394
- <tbody>
395
- <tr>
396
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
397
- <td><?php _e('State', 'woocommerce-checkout-manager'); ?></td>
398
- <td><input name="wccs_settings[check][wccs_opt_9_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_9_s'])) ? "checked='checked'" : ""; ?> /></td>
399
- <td></td>
400
- <td></td>
401
- <td></td>
402
- </tr>
403
- </tbody>
404
- <div style="margin:20px 0 15px 10px;color:green;font-size:18px;float:left;">= <?php _e('Shipping Section', 'woocommerce-checkout-manager'); ?> =</div>
405
- </table>
406
- <div style="padding:5px 10px;font-weight:700;color:green;" class="clear_dwccm">
407
-
408
-
409
- <div class="updated clear_wccm data">
410
- <div class="clear_wccm title">
411
- <a href="http://www.trottyzone.com/product/woocommerce-checkout-manager-pro/"><?php _e('TRY THE PRO VERSION', 'woocommerce-checkout-manager'); ?></a><br /><span class="small"><?php _e('includes these field types', 'woocommerce-checkout-manager'); ?></span> &#8594;
412
- </div>
413
- <ul>
414
- <li><?php _e('Text Area', 'woocommerce-checkout-manager'); ?></li>
415
- <li><?php _e('Password', 'woocommerce-checkout-manager'); ?></li>
416
- <li><?php _e('Mult-Select', 'woocommerce-checkout-manager'); ?></li>
417
- </ul>
418
- <ul>
419
- <li><?php _e('Radio Button (Unlimited Options)', 'woocommerce-checkout-manager'); ?></li>
420
- <li><?php _e('Select Options (Unlimited Options)', 'woocommerce-checkout-manager'); ?></li>
421
- <li><?php _e('Time Picker', 'woocommerce-checkout-manager'); ?></li>
422
- </ul>
423
- <ul>
424
- <li><?php _e('Text/ Html Swapper', 'woocommerce-checkout-manager'); ?></li>
425
- <li><?php _e('Color Picker', 'woocommerce-checkout-manager'); ?></li>
426
- <li><?php _e('Heading', 'woocommerce-checkout-manager'); ?></li>
427
- </ul>
428
- <ul>
429
- <li><?php _e('Check Box (Put your own options)', 'woocommerce-checkout-manager'); ?></li>
430
- <li><strong><a href="http://www.trottyzone.com/product/woocommerce-checkout-manager-pro/"><?php _e('more features. . .', 'woocommerce-checkout-manager'); ?></a></strong></li>
431
- </ul>
432
- </div>
433
- </div>
434
- <div style="margin:20px 0 15px 10px;color:green;font-size:18px;float:left;">= <?php _e('Add New Field Section', 'woocommerce-checkout-manager'); ?> =</div>
435
- <table class="widefat" border="1" >
436
- <thead>
437
- <tr>
438
- <th><?php _e('Enable Title - Additional information', 'atc-menu'); ?></th>
439
- <th>
440
- <input style="float:left;" name="wccs_settings[checkness][checkbox12]" type="checkbox" value="true" <?php echo (isset($options['checkness']['checkbox12'])) ? "checked='checked'": ""; ?> /></th>
441
- <th><?php _e('Checkout Page', 'atc-menu'); ?></th>
442
- <th>
443
- <input style="float:left;" name="wccs_settings[checkness][checkbox1]" type="checkbox" value="true" <?php echo (isset($options['checkness']['checkbox1'])) ? "checked='checked'": ""; ?> /></th>
444
- <th><?php _e('Checkout Details and Email Receipt', 'atc-menu'); ?></th>
445
- </tr>
446
- </thead>
447
- </table>
448
- <style type="text/css">
449
- .small {
450
- font-size: 10px;
451
- }
452
- .wooccm_feed {
453
- float: right;
454
- margin-right: 10px;
455
- font-size: 14px;
456
- }
457
- .wccs-clone {
458
- display:none;
459
- }
460
- .clear_wccm {
461
- float: left;
462
- }
463
- p.submit {
464
- float: right;
465
- padding: 0 !IMPORTANT;
466
- margin: 0 !IMPORTANT;
467
- }
468
- .clear_wccm.title {
469
- margin-top: 30px;
470
- margin-right: 12px;
471
- margin-left: 12px;
472
- width: 14%;
473
- }
474
- .clear_wccm.data {
475
- width: 97%;
476
- }
477
- .clear_wccm ul {
478
- float: left;
479
- padding: 0 32px;
480
- list-style: square;
481
- }
482
- .widefat input {
483
- float: right;
484
- }
485
- .wccs_replace {
486
- width: 20%;
487
- }
488
- .wccs-order {
489
- cursor:move;
490
- }
491
- .wccs-table > tbody > tr > td {
492
- background: #fff;
493
- border-right: 1px solid #ededed;
494
- border-bottom: 1px solid #ededed;
495
- padding: 8px;
496
- position: relative;
497
- }
498
- .wccs-table > tbody > tr:last-child td { border-bottom: 0 none; }
499
- .wccs-table > tbody > tr td:last-child { border-right: 0 none; }
500
- .wccs-table > thead > tr > th { border-right: 1px solid #e1e1e1; }
501
- .wccs-table > thead > tr > th:last-child { border-right: 0 none; }
502
- .wccs-table tr td.wccs-order,
503
- .wccs-table tr th.wccs-order {
504
- width: 16px;
505
- text-align: center;
506
- vertical-align: middle;
507
- color: #aaa;
508
- text-shadow: #fff 0 1px 0;
509
- }
510
- .wccs-table .wccs-remove {
511
- font-size: 16px;
512
- font-weight: 700;
513
- vertical-align: middle;
514
- }
515
- .wccs-table input[type="text"] {
516
- width: 100%;
517
- }
518
- .wccs-table-footer {
519
- position: relative;
520
- overflow: hidden;
521
- margin-top: 10px;
522
- padding: 8px 0;
523
- }
524
- </style>
525
- <table class="widefat wccs-table" border="1">
526
- <thead>
527
- <tr>
528
- <th style="width:5%;" class="wccs-order" title="<?php esc_attr_e( 'Change order' , 'woocommerce-checkout-manager' ); ?>"></th>
529
- <th><?php _e('Label' , 'woocommerce-checkout-manager' ); ?></th>
530
- <th><?php _e('Placeholder' , 'woocommerce-checkout-manager' ); ?></th>
531
- <th><?php _e('Option A' , 'woocommerce-checkout-manager' ); ?></th>
532
- <th><?php _e('Options B' , 'woocommerce-checkout-manager' ); ?></th>
533
- <th width="15%"><?php _e('Choose Type' , 'woocommerce-checkout-manager' ); ?></th>
534
- <th width="10%"><?php _e('Abbreviation' , 'woocommerce-checkout-manager' ); ?></th>
535
- <th width="9%"><?php _e('Required Attribute' , 'woocommerce-checkout-manager' ); ?></th>
536
- <th scope="col" title="<?php esc_attr_e( 'Remove button', 'woocommerce-checkout-manager' ); ?>"><!-- remove --></th>
537
- </tr>
538
- </thead>
539
- <tbody>
540
- <?php
541
- if ( isset ( $options['buttons'] ) ) :
542
- // Loop through all the buttons
543
  for ( $i = 0; $i < count( $options['buttons'] ); $i++ ) :
544
  if ( ! isset( $options['buttons'][$i] ) )
545
- break;
546
- ?>
547
- <tr valign="top" class="wccs-row">
548
- <td class="wccs-order" title="<?php esc_attr_e( 'Change order', 'woocommerce-checkout-manager' ); ?>"><?php echo $i + 1; ?></td>
549
-
550
- <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][label]"
551
- value="<?php echo esc_attr($options['buttons'][$i]['label']); ?>" /></td>
552
-
553
- <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][placeholder]"
554
- value="<?php echo esc_attr($options['buttons'][$i]['placeholder']); ?>" /></td>
555
-
556
- <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][option_a]"
557
- value="<?php echo esc_attr( $options['buttons'][$i]['option_a'] ); ?>" /></td>
558
-
559
- <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][option_b]"
560
- value="<?php echo esc_attr( $options['buttons'][$i]['option_b'] ); ?>" /></td>
561
-
562
- <td>
563
- <select name="wccs_settings[buttons][<?php echo $i; ?>][type]" > <!--Call run() function-->
564
- <option value="text" <?php selected( $options['buttons'][$i]['type'], 'text' ); ?>>Text Input</option>
565
- <option value="select" <?php selected( $options['buttons'][$i]['type'], 'select' ); ?>>Select Options</option>
566
- <option value="date" <?php selected( $options['buttons'][$i]['type'], 'date' ); ?>>Date Picker</option>
567
- <option value="checkbox" <?php selected( $options['buttons'][$i]['type'], 'checkbox' ); ?>>Checkbox (1, 0)</option>
568
- </select>
569
- </td>
570
- <td><input type="text" maxlength="10" name="wccs_settings[buttons][<?php echo $i; ?>][cow]"
571
- value="<?php echo esc_attr($options['buttons'][$i]['cow']); ?>" /></td>
572
-
573
- <td style="text-align:center;"><input style="float:none;" name="wccs_settings[buttons][<?php echo $i; ?>][checkbox]" type="checkbox" value="true" <?php echo (isset($options['buttons'][$i]['checkbox'])) ? "checked='checked'": ""; ?> /></td>
574
- <td class="wccs-remove"><a class="wccs-remove-button" href="javascript:;" title="<?php esc_attr_e( 'Remove Field' , 'woocommerce-checkout-manager' ); ?>">&times;</a></td>
575
- </tr>
576
- <?php endfor; endif; ?>
577
- <!-- Empty -->
578
- <?php $i = 999; ?>
579
- <tr valign="top" class="wccs-clone" >
580
- <td class="wccs-order" title="<?php esc_attr_e( 'Change order' , 'woocommerce-checkout-manager' ); ?>"><?php echo $i; ?></td>
581
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
582
- <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][label]"
583
- title="<?php esc_attr_e( 'Label of the New Field', 'woocommerce-checkout-manager' ); ?>" value="" /></td>
584
- <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][placeholder]"
585
- title="<?php esc_attr_e( 'Placeholder - Preview of Data to Input', 'woocommerce-checkout-manager' ); ?>" value=" " /></td>
586
- <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][option_a]"
587
- title="<?php esc_attr_e( 'Insert Option A', 'woocommerce-checkout-manager' ); ?>" value="" /></td>
588
- <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][option_b]"
589
- title="<?php esc_attr_e( 'Insert Option B', 'woocommerce-checkout-manager' ); ?>" value="" /></td>
590
- <td>
591
- <select name="wccs_settings[buttons][<?php echo $i; ?>][type]" > <!--Call run() function-->
592
- <option value="text" >Text Input</option>
593
- <option value="select" >Select Options</option>
594
- <option value="date" >Date Picker</option>
595
- <option value="checkbox" >Checkbox (1, 0)</option>
596
- </select>
597
- </td>
598
- <td><input type="text" maxlength="5" name="wccs_settings[buttons][<?php echo $i; ?>][cow]"
599
- title="<?php esc_attr_e( 'Abbreviation (No spaces)', 'woocommerce-checkout-manager' ); ?>" value="" /></td>
600
- <td style="text-align:center;"><input style="float:none;" name="wccs_settings[buttons][<?php echo $i; ?>][checkbox]" type="checkbox"
601
- title="<?php esc_attr_e( 'Add/Remove Required Attribute', 'woocommerce-checkout-manager' ); ?>" value=" " /></td>
602
- <td class="wccs-remove"><a class="wccs-remove-button" href="javascript:;" title="<?php esc_attr_e( 'Remove Field' , 'woocommerce-checkout-manager' ); ?>">&times;</a></td>
603
- </tr>
604
- </tbody>
605
- </table>
606
- <div class="wccs-table-footer">
607
- <a href="javascript:;" id="wccs-add-button" class="button-secondary"><?php _e( '+ Add New Field' , 'woocommerce-checkout-manager' ); ?></a>
608
- </div>
 
 
 
 
609
  </form>
610
- <?php
611
- }
 
 
 
 
612
  // Build array of links for rendering in installed plugins list
613
  function wccs_admin_plugin_actions($links) {
614
  $wccs_plugin_links = array(
615
- '<a href="options-general.php?page=woocommerce-checkout-manager/woocommerce-checkout-manager.php">'.__('Settings').'</a>',
616
- '<a href="http://www.trottyzone.com/forums/forum/wordpress-plugins/">'.__('Support').'</a>',
617
  );
618
  return array_merge( $wccs_plugin_links, $links );
619
  }
 
620
  function wccs_scripts( $hook_suffix ) {
621
- if ( $hook_suffix == 'settings_page_woocommerce-checkout-manager/woocommerce-checkout-manager' ) {
622
- wp_enqueue_script( 'script_wccs', plugins_url( 'script_wccs.js', __FILE__ ), array( 'jquery' ), '1.2' );
 
623
  if(!wp_script_is('jquery-ui-sortable', 'queue')){
624
  wp_enqueue_script('jquery-ui-sortable');
625
- }
626
  }
627
  }
628
- add_action( 'admin_enqueue_scripts', 'wccs_scripts' );
629
- // ================== First Name ===================
630
- function wccs_override_checkout_fields1($fields1) {
631
- $options = get_option( 'wccs_settings' );
632
- if ( 1 == ($options['checkness']['wccs_opt_1'] ) )
633
- unset($fields1['billing']['billing_first_name']);
634
- return $fields1;
635
- }
636
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields1' );
637
- function wccs_override_required_fields1( $address_fields1 ) {
638
  $options = get_option( 'wccs_settings' );
639
- if ( 1 == ($options['checkness']['wccs_rq_1'] ) )
640
- $address_fields1['billing_first_name']['required'] = false;
641
- return $address_fields1;
642
  }
643
- add_filter( 'woocommerce_billing_fields', 'wccs_override_required_fields1', 10, 1 );
644
- // replace label and placeholder
645
- function custom_replace_checkout_fields( $fields ) {
646
- $options = get_option( 'wccs_settings' );
647
- if ( ! empty( $options['replace']['placeholder'] ) )
648
  $fields['billing']['billing_first_name']['placeholder'] = wpml_string_wccm($options['replace']['placeholder']);
649
- return $fields;
650
  }
651
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fields' );
652
- function custom_replace_checkout_fieldsa( $fields ) {
653
- $options = get_option( 'wccs_settings' );
654
- if ( ! empty( $options['replace']['label'] ) )
655
  $fields['billing']['billing_first_name']['label'] = wpml_string_wccm($options['replace']['label']);
656
- return $fields;
657
  }
658
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldsa' );
659
- // ========== Last Name ==============
660
- function wccs_override_checkout_fields2($fields2) {
661
- $options = get_option( 'wccs_settings' );
662
- if ( 1 == ($options['checkness']['wccs_opt_2'] ) )
663
- unset($fields2['billing']['billing_last_name']);
664
- return $fields2;
665
  }
666
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields2' );
667
- function wccs_override_required_fields2( $address_fields2 ) {
668
- $options = get_option( 'wccs_settings' );
669
- if ( 1 == ($options['checkness']['wccs_rq_2'] ) )
670
- $address_fields2['billing_last_name']['required'] = false;
671
- return $address_fields2;
672
  }
673
- add_filter( 'woocommerce_billing_fields', 'wccs_override_required_fields2', 10, 1 );
674
- // replace label and placeholder
675
- function custom_replace_checkout_fields1( $fields ) {
676
- $options = get_option( 'wccs_settings' );
677
- if ( ! empty( $options['replace']['placeholder1'] ) )
678
- $fields['billing']['billing_last_name']['placeholder'] = wpml_string_wccm($options['replace']['placeholder1']);
679
- return $fields;
680
  }
681
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fields1' );
682
- function custom_replace_checkout_fieldsb( $fields ) {
683
- $options = get_option( 'wccs_settings' );
684
- if ( ! empty( $options['replace']['label1'] ) )
685
- $fields['billing']['billing_last_name']['label'] = wpml_string_wccm($options['replace']['label1']);
686
- return $fields;
687
  }
688
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldsb' );
689
- // ============ Company ==============
690
- function wccs_override_checkout_fields3($fields3) {
691
- $options = get_option( 'wccs_settings' );
692
- if ( 1 == ($options['checkness']['wccs_opt_3'] ) )
693
- unset($fields3['billing']['billing_company']);
694
- return $fields3;
695
  }
696
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields3' );
697
- // replace label and placeholder
698
- function custom_replace_checkout_fields2( $fields ) {
699
- $options = get_option( 'wccs_settings' );
700
- if ( ! empty( $options['replace']['placeholder2'] ) )
701
- $fields['billing']['billing_company']['placeholder'] = wpml_string_wccm($options['replace']['placeholder2']);
702
- return $fields;
703
  }
704
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fields2' );
705
- function custom_replace_checkout_fieldsc( $fields ) {
706
- $options = get_option( 'wccs_settings' );
707
- if ( ! empty( $options['replace']['label5'] ) )
708
- $fields['billing']['billing_company']['label'] = wpml_string_wccm($options['replace']['label5']);
709
- return $fields;
710
  }
711
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldsc' );
712
- // ============ Address 1 ==============
713
- function wccs_override_checkout_fields4($fields4) {
714
- $options = get_option( 'wccs_settings' );
715
- if ( 1 == ($options['checkness']['wccs_opt_4'] ) )
716
- unset($fields4['billing']['billing_address_1']);
717
- return $fields4;
718
  }
719
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields4' );
720
- // ============ Address 2 ===============
721
- function wccs_override_checkout_fields5($fields5) {
722
- $options = get_option( 'wccs_settings' );
723
- if ( 1 == ($options['checkness']['wccs_opt_5'] ) )
724
- unset($fields5['billing']['billing_address_2']);
725
- return $fields5;
726
- }
727
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields5' );
728
- // ============= City ================
729
- function wccs_override_checkout_fields6($fields6) {
730
- $options = get_option( 'wccs_settings' );
731
- if ( 1 == ($options['checkness']['wccs_opt_6'] ) )
732
- unset($fields6['billing']['billing_city']);
733
- return $fields6;
734
  }
735
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields6' );
736
- // ============= Postal Code ================
737
- function wccs_override_checkout_fields7($fields7) {
738
- $options = get_option( 'wccs_settings' );
739
- if ( 1 == ($options['checkness']['wccs_opt_7'] ) )
740
- unset($fields7['billing']['billing_postcode']);
741
- return $fields7;
742
  }
743
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields7' );
744
- // =================== Country==================
745
- function wccs_override_checkout_fields8($fields8) {
746
- $options = get_option( 'wccs_settings' );
747
- if ( 1 == ($options['checkness']['wccs_opt_8'] ) )
748
- unset($fields8['billing']['billing_country']);
749
- return $fields8;
750
  }
751
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields8' );
752
- function wccs_override_required_fields8( $address_fields8 ) {
753
- $options = get_option( 'wccs_settings' );
754
- if ( 1 == ($options['checkness']['wccs_rq_8'] ) )
755
- $address_fields8['billing_country']['required'] = false;
756
- return $address_fields8;
757
  }
758
- add_filter( 'woocommerce_billing_fields', 'wccs_override_required_fields8', 10, 1 );
759
- function custom_replace_checkout_fieldsh( $fields ) {
760
- $options = get_option( 'wccs_settings' );
761
- if ( ! empty( $options['replace']['label2'] ) )
762
  $fields['billing']['billing_country']['label'] = wpml_string_wccm($options['replace']['label2']);
763
- return $fields;
764
- }
765
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldsh' );
766
- // ================= State ===================
767
- function wccs_override_checkout_fields9($fields9) {
768
- $options = get_option( 'wccs_settings' );
769
- if ( 1 == ($options['checkness']['wccs_opt_9'] ) )
770
- unset($fields9['billing']['billing_state']);
771
- return $fields9;
772
- }
773
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields9' );
774
- // =============== Phone ======================
775
- function wccs_override_checkout_fields10($fields10) {
776
- $options = get_option( 'wccs_settings' );
777
- if ( 1 == ($options['checkness']['wccs_opt_10'] ) )
778
- unset($fields10['billing']['billing_phone']);
779
- return $fields10;
780
- }
781
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields10' );
782
- function wccs_override_required_fields10( $address_fields10 ) {
783
- $options = get_option( 'wccs_settings' );
784
- if ( 1 == ($options['checkness']['wccs_rq_10'] ) )
785
- $address_fields10['billing_phone']['required'] = false;
786
- return $address_fields10;
787
  }
788
- add_filter( 'woocommerce_billing_fields', 'wccs_override_required_fields10', 10, 1 );
789
- // replace label and placeholder
790
- function custom_replace_checkout_fields9( $fields ) {
791
- $options = get_option( 'wccs_settings' );
792
- if ( ! empty( $options['replace']['placeholder3'] ) )
793
  $fields['billing']['billing_phone']['placeholder'] = wpml_string_wccm($options['replace']['placeholder3']);
794
- return $fields;
795
  }
796
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fields9' );
797
- function custom_replace_checkout_fieldsj( $fields ) {
798
- $options = get_option( 'wccs_settings' );
799
- if ( ! empty( $options['replace']['label3'] ) )
800
  $fields['billing']['billing_phone']['label'] = wpml_string_wccm($options['replace']['label3']);
801
- return $fields;
802
  }
803
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldsj' );
804
- // ==================== Email ========================
805
- function wccs_override_checkout_fields11($fields11) {
806
- $options = get_option( 'wccs_settings' );
807
- if ( 1 == ($options['checkness']['wccs_opt_11'] ) )
808
- unset($fields11['billing']['billing_email']);
809
- return $fields11;
810
  }
811
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields11' );
812
- function wccs_override_required_fields11( $address_fields11 ) {
813
- $options = get_option( 'wccs_settings' );
814
- if ( 1 == ($options['checkness']['wccs_rq_11'] ) )
815
- $address_fields11['billing_email']['required'] = false;
816
- return $address_fields11;
817
- }
818
- add_filter( 'woocommerce_billing_fields', 'wccs_override_required_fields11', 10, 1 );
819
- // replace label and placeholder
820
- function custom_replace_checkout_fields10( $fields ) {
821
- $options = get_option( 'wccs_settings' );
822
- if ( ! empty( $options['replace']['placeholder4'] ) )
823
  $fields['billing']['billing_email']['placeholder'] = wpml_string_wccm($options['replace']['placeholder4']);
824
- return $fields;
825
  }
826
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fields10' );
827
- function custom_replace_checkout_fieldsk( $fields ) {
828
- $options = get_option( 'wccs_settings' );
829
- if ( ! empty( $options['replace']['label4'] ) )
830
  $fields['billing']['billing_email']['label'] = wpml_string_wccm($options['replace']['label4']);
831
- return $fields;
832
  }
833
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldsk' );
834
- // ===================== Order Comments ==========================
835
- function wccs_override_checkout_fields12($fields12) {
836
- $options = get_option( 'wccs_settings' );
837
- if ( 1 == ($options['checkness']['wccs_opt_12'] ) )
838
- unset($fields12['order']['order_comments']);
839
- return $fields12;
840
  }
841
- add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields12' );
842
- // replace label and placeholder
843
- function custom_replace_checkout_fields11( $fields ) {
844
- $options = get_option( 'wccs_settings' );
845
- if ( ! empty( $options['replace']['placeholder11'] ) )
846
  $fields['order']['order_comments']['placeholder'] = wpml_string_wccm($options['replace']['placeholder11']);
847
- return $fields;
848
  }
849
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fields11' );
850
- function custom_replace_checkout_fieldsl( $fields ) {
851
- $options = get_option( 'wccs_settings' );
852
- if ( ! empty( $options['replace']['label11'] ) )
853
  $fields['order']['order_comments']['label'] = wpml_string_wccm($options['replace']['label11']);
854
- return $fields;
855
  }
856
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldsl' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
857
  function wccs_add_title() {
858
  $options = get_option( 'wccs_settings' );
859
- if (true == ($options['checkness']['checkbox12']) )
860
- echo '<div class="add_info_wccs"><br><h3>' . __( 'Additional information', 'woocommerce-checkout-manager' ) . '</h3></div>';
861
  }
862
- add_action('woocommerce_after_checkout_billing_form', 'wccs_add_title');
 
 
863
  // =============== Add the field to the checkout =====================
864
  function wccs_custom_checkout_field( $checkout ) {
865
  $options = get_option( 'wccs_settings' );
866
- if ( count( $options['buttons'] ) > 0 ) : ?>
867
- <?php
868
- $i = 0;
869
- // Loop through each button
870
- foreach ( $options['buttons'] as $btn ) :
871
- $label = ( isset( $btn['label'] ) ) ? $btn['label'] : '';
872
- ?>
873
- <?php
874
- if ( ! empty( $btn['label'] ) && ($btn['type'] == 'text') ) {
875
- woocommerce_form_field( ''.$btn['cow'].'' , array(
876
- 'type' => 'text',
877
- 'class' => array('wccs-field-class wccs-form-row-wide'),
878
- 'label' => wpml_string_wccm(''.$btn['label'].''),
879
- 'required' => $btn['checkbox'],
880
- 'placeholder' => wpml_string_wccm(''.$btn['placeholder'].''),
881
- ), $checkout->get_value( ''.$btn['cow'].'' ));
882
- }
883
- if ( ! empty( $btn['label'] ) && ($btn['type'] == 'select') ) {
884
- woocommerce_form_field( ''.$btn['cow'].'' , array(
885
- 'type' => 'select',
886
- 'class' => array('wccs-field-class wccs-form-row-wide'),
887
- 'label' => wpml_string_wccm(''.$btn['label'].''),
888
- 'options' => array(
889
- '' => __('Select below', 'woocommerce-checkout-manager' ),
890
- ''.wpml_string_wccm(''.$btn['option_a'].'').'' => ''.wpml_string_wccm(''.$btn['option_a'].'').'',
891
- ''.wpml_string_wccm(''.$btn['option_b'].'').'' => ''.wpml_string_wccm(''.$btn['option_b'].'').''
892
- ),
893
- 'required' => $btn['checkbox'],
894
- 'placeholder' => wpml_string_wccm(''.$btn['placeholder'].''),
895
- ), $checkout->get_value( ''.$btn['cow'].'' ));
896
- }
897
- if ( ! empty( $btn['label'] ) && ($btn['type'] == 'date') ) {
898
- echo '<script type="text/javascript">
899
- jQuery(document).ready(function() {
900
- jQuery(".MyDate-'.$btn['cow'].' #'.$btn['cow'].'").datepicker({
901
- dateFormat : "dd-mm-yy"
902
- });
903
- });
904
- </script>';
905
- woocommerce_form_field( ''.$btn['cow'].'' , array(
906
- 'type' => 'text',
907
- 'class' => array('wccs-field-class MyDate-'.$btn['cow'].' wccs-form-row-wide'),
908
- 'label' => wpml_string_wccm(''.$btn['label'].''),
909
- 'required' => $btn['checkbox'],
910
- 'placeholder' => wpml_string_wccm(''.$btn['placeholder'].''),
911
- ), $checkout->get_value( ''.$btn['cow'].'' ));
912
- }
913
- if ( ! empty( $btn['label'] ) && ($btn['type'] == 'checkbox') ) {
914
- woocommerce_form_field( ''.$btn['cow'].'' , array(
915
- 'type' => 'checkbox',
916
- 'class' => array('wccs-field-class wccs-form-row-wide'),
917
- 'label' => wpml_string_wccm(''.$btn['label'].''),
918
- 'required' => $btn['checkbox'],
919
- 'placeholder' => wpml_string_wccm(''.$btn['placeholder'].''),
920
- ), $checkout->get_value( ''.$btn['cow'].'' ));
921
- }
922
- ?>
923
- <?php
924
- $i++;
925
- endforeach;
926
- ?>
927
- <?php
928
  endif;
929
  }
930
- add_action('woocommerce_after_checkout_billing_form', 'wccs_custom_checkout_field');
 
931
  // ============================== Update the order meta with field value ==============================
932
  function wccs_custom_checkout_field_update_order_meta( $order_id ) {
933
  $options = get_option( 'wccs_settings' );
934
- if ( count( $options['buttons'] ) > 0 ) :
935
- $i = 0;
936
- // Loop through each button
937
- foreach ( $options['buttons'] as $btn ) :
938
- $label = ( isset( $btn['label'] ) ) ? $btn['label'] : '';
939
- if ( ! empty( $btn['label'] ) )
940
- if ( $_POST[ ''.$btn['cow'].'' ])
941
- update_post_meta( $order_id, ''.$btn['label'].'' , esc_attr( $_POST[ ''.$btn['cow'].'' ] ));
942
- $i++;
943
- endforeach;
944
- endif;
945
  }
946
- add_action('woocommerce_checkout_update_order_meta', 'wccs_custom_checkout_field_update_order_meta');
947
  // =============== Add to email (working) =====================
948
  add_filter('woocommerce_email_order_meta_keys', 'wccs_custom_checkout_field_order_meta_keys');
949
  function wccs_custom_checkout_field_order_meta_keys( $keys ) {
950
  $options = get_option( 'wccs_settings' );
951
- if ( count( $options['buttons'] ) > 0 ) :
952
- $i = 0;
953
- // Loop through each button
954
- foreach ( $options['buttons'] as $btn ) :
955
- $label = ( isset( $btn['label'] ) ) ? $btn['label'] : '';
956
- if ( ! empty( $btn['label'] ) )
957
- $keys[''.wpml_string_wccm($btn['label']).''] = ''.$btn['label'].'';
958
- $i++;
959
- endforeach;
960
- return $keys;
961
- endif;
962
  }
 
 
963
  // ================ Style the Email =======================
964
- add_action('woocommerce_email_after_order_table', 'wccs_custom_style_checkout_email');
965
  function wccs_custom_style_checkout_email() {
966
  $options = get_option( 'wccs_settings' );
967
- if (true == ($options['checkness']['checkbox1']) )
968
- echo '<h2>' . __( 'Additional information', 'woocommerce-checkout-manager' ) . '</h2>';
969
  }
 
 
970
  // ============== Process the checkout (if needed activate) ==================
971
  function wccs_custom_checkout_field_process() {
 
972
  $options = get_option( 'wccs_settings' );
973
- if ( count( $options['buttons'] ) > 0 ) :
974
- $i = 0;
975
- // Loop through each button
976
- foreach ( $options['buttons'] as $btn ) :
977
- $label = ( isset( $btn['label'] ) ) ? $btn['label'] : '';
978
- global $woocommerce;
979
- if ( (!$_POST[ ''.$btn['cow'].'' ] ) && (true == ($btn['checkbox']) ) )
980
- $woocommerce->add_error( '<strong>'.$btn['label'].'</strong> '. __('is a required field', 'woocommerce-checkout-manager' ) . ' ');
981
- $i++;
982
- endforeach;
983
- endif;
984
- }
985
- add_action('woocommerce_checkout_process', 'wccs_custom_checkout_field_process');
986
- function wccs_options_validatew() {
987
- $options = get_option( 'wccs_settings' );
988
- if ( empty( $options['replace']['label'] ) )
989
- unset( $options['replace']['label'] );
990
  }
 
991
  function wccs_options_validate( $input ) {
992
  $options = get_option( 'wccs_settings' );
993
- // Don't save empty inputs
994
  foreach( $input['buttons'] as $i => $btn ) :
995
 
996
- if( function_exists( 'icl_register_string' ) ) {
997
-
998
- icl_register_string('WooCommerce Checkout Manager', ''.$btn['label'].'', ''.$btn['label'].'');
999
- icl_register_string('WooCommerce Checkout Manager', ''.$btn['placeholder'].'', ''.$btn['placeholder'].'');
1000
- icl_register_string('WooCommerce Checkout Manager', ''.$btn['option_a'].'', ''.$btn['option_a'].'');
1001
- icl_register_string('WooCommerce Checkout Manager', ''.$btn['option_b'].'', ''.$btn['option_b'].'');
1002
-
1003
- }
1004
- if ( empty( $btn['label'] ) )
1005
- unset( $input['buttons'][$i], $btn );
 
 
 
 
 
 
 
 
1006
  endforeach;
1007
 
 
1008
  foreach( $input['replace'] as $type => $value ) :
1009
  if( function_exists( 'icl_register_string' ) ) {
1010
  if(!empty($value) && $value!=''){
1011
  icl_register_string('WooCommerce Checkout Manager', ''.$value.'', ''.$value.'');
1012
  }
1013
  }
1014
- if ( empty( $btn['label'] ) )
1015
- unset( $input['buttons'][$i], $btn );
1016
  endforeach;
1017
 
 
1018
 
1019
  $input['buttons'] = array_values( $input['buttons'] );
1020
  return $input;
1021
  }
 
 
 
1022
  function wccs_custom_checkout_details( $order_id ) {
1023
  $options = get_option( 'wccs_settings' );
1024
- if (true == ($options['checkness']['checkbox1']) ) {
1025
- echo '<h2>' . __( 'Additional information', 'woocommerce-checkout-manager' ) . '</h2>';
1026
- }
1027
- if ( count( $options['buttons'] ) > 0 ) :
1028
- $i = 0;
1029
- // Loop through each button
1030
- foreach ( $options['buttons'] as $btn ) :
1031
- $label = ( isset( $btn['label'] ) ) ? $btn['label'] : '';
1032
- $order_object = new WC_Order( $order_id );
1033
- echo '<dt>'.wpml_string_wccm($btn['label']).':</dt><dd>'.get_post_meta( $order_id->id , ''.$btn['label'].'', true).'</dd>';
1034
- $i++;
1035
- endforeach;
1036
- endif;
1037
- }
1038
- add_action('woocommerce_order_details_after_order_table', 'wccs_custom_checkout_details');
1039
- // ================== First Name ===================
1040
- function wccs_shipping_checkout_fields1( $fields1 ) {
1041
- $options = get_option( 'wccs_settings' );
1042
- if ( 1 == ($options['check']['wccs_opt_1_s'] ) )
1043
- unset($fields1['shipping']['shipping_first_name']);
1044
- return $fields1;
1045
- }
1046
- add_filter( 'woocommerce_checkout_fields' , 'wccs_shipping_checkout_fields1' );
1047
- function wccs_shipping_required_fields1( $address_fields1 ) {
1048
- $options = get_option( 'wccs_settings' );
1049
- if ( 1 == ($options['check']['wccs_rq_1_s'] ) )
1050
- $address_fields1['shipping_first_name']['required'] = false;
1051
- return $address_fields1;
1052
- }
1053
- add_filter( 'woocommerce_shipping_fields', 'wccs_shipping_required_fields1', 10, 1 );
1054
- // replace label and placeholder
1055
- function custom_replace_checkout_fieldss( $fields ) {
1056
- $options = get_option( 'wccs_settings' );
1057
- if ( ! empty( $options['replace']['placeholder_s'] ) )
1058
- $fields['shipping']['shipping_first_name']['placeholder'] = wpml_string_wccm($options['replace']['placeholder_s']);
1059
- return $fields;
1060
- }
1061
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldss' );
1062
- function custom_replace_checkout_fieldssa( $fields ) {
1063
- $options = get_option( 'wccs_settings' );
1064
- if ( ! empty( $options['replace']['label_s'] ) )
1065
- $fields['shipping']['shipping_first_name']['label'] = wpml_string_wccm($options['replace']['label_s']);
1066
- return $fields;
1067
- }
1068
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldssa' );
1069
- // ========== Last Name ==============
1070
- function wccs_shipping_checkout_fields2( $fields2 ) {
1071
- $options = get_option( 'wccs_settings' );
1072
- if ( 1 == ($options['check']['wccs_opt_2_s'] ) )
1073
- unset($fields2['shipping']['shipping_last_name']);
1074
- return $fields2;
1075
- }
1076
- add_filter( 'woocommerce_checkout_fields' , 'wccs_shipping_checkout_fields2' );
1077
- function wccs_shipping_required_fields2( $address_fields2 ) {
1078
- $options = get_option( 'wccs_settings' );
1079
- if ( 1 == ($options['check']['wccs_rq_2_s'] ) )
1080
- $address_fields2['shipping_last_name']['required'] = false;
1081
- return $address_fields2;
1082
- }
1083
- add_filter( 'woocommerce_shipping_fields', 'wccs_shipping_required_fields2', 10, 1 );
1084
- // replace label and placeholder
1085
- function custom_replace_checkout_fieldss1( $fields ) {
1086
- $options = get_option( 'wccs_settings' );
1087
- if ( ! empty( $options['replace']['placeholder_s1'] ) )
1088
- $fields['shipping']['shipping_last_name']['placeholder'] = wpml_string_wccm($options['replace']['placeholder_s1']);
1089
- return $fields;
1090
- }
1091
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldss1' );
1092
- function custom_replace_checkout_fieldssb( $fields ) {
1093
- $options = get_option( 'wccs_settings' );
1094
- if ( ! empty( $options['replace']['label_s1'] ) )
1095
- $fields['shipping']['shipping_last_name']['label'] = wpml_string_wccm($options['replace']['label_s1']);
1096
- return $fields;
1097
- }
1098
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldssb' );
1099
- // ============ Company ==============
1100
- function wccs_shipping_checkout_fields3( $fields3 ) {
1101
- $options = get_option( 'wccs_settings' );
1102
- if ( 1 == ($options['check']['wccs_opt_3_s'] ) )
1103
- unset($fields3['shipping']['shipping_company']);
1104
- return $fields3;
1105
- }
1106
- add_filter( 'woocommerce_checkout_fields' , 'wccs_shipping_checkout_fields3' );
1107
- // replace label and placeholder
1108
- function custom_replace_checkout_fieldss2( $fields ) {
1109
- $options = get_option( 'wccs_settings' );
1110
- if ( ! empty( $options['replace']['placeholder_s2'] ) )
1111
- $fields['shipping']['shipping_company']['placeholder'] = wpml_string_wccm($options['replace']['placeholder_s2']);
1112
- return $fields;
1113
- }
1114
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldss2' );
1115
- function custom_replace_checkout_fieldssc( $fields ) {
1116
- $options = get_option( 'wccs_settings' );
1117
- if ( ! empty( $options['replace']['label_s2'] ) )
1118
- $fields['shipping']['shipping_company']['label'] = wpml_string_wccm($options['replace']['label_s2']);
1119
- return $fields;
1120
- }
1121
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldssc' );
1122
- // Hook in
1123
- add_filter( 'woocommerce_checkout_fields' , 'b1_custom_override_checkout_fields' );
1124
- // Our hooked in function - $fields is passed via the filter!
1125
- function b1_custom_override_checkout_fields( $fields ) {
1126
- $options = get_option( 'wccs_settings' );
1127
- if ( 1 == ($options['check']['wccs_opt_4_s'] ) )
1128
- unset($fields['shipping']['shipping_address_1']);
1129
- return $fields;
1130
- }
1131
- // Hook in
1132
- add_filter( 'woocommerce_checkout_fields' , 'b2_custom_override_checkout_fields' );
1133
- // Our hooked in function - $fields is passed via the filter!
1134
- function b2_custom_override_checkout_fields( $fields ) {
1135
- $options = get_option( 'wccs_settings' );
1136
- if ( 1 == ($options['check']['wccs_opt_5_s'] ) )
1137
- unset($fields['shipping']['shipping_address_2']);
1138
- return $fields;
1139
- }
1140
- // Hook in
1141
- add_filter( 'woocommerce_checkout_fields' , 'c_custom_override_checkout_fields' );
1142
- // Our hooked in function - $fields is passed via the filter!
1143
- function c_custom_override_checkout_fields( $fields ) {
1144
- $options = get_option( 'wccs_settings' );
1145
- if ( 1 == ($options['check']['wccs_opt_6_s'] ) )
1146
- unset($fields['shipping']['shipping_city']);
1147
- return $fields;
1148
- }
1149
- // Hook in
1150
- add_filter( 'woocommerce_checkout_fields' , 'sp_custom_override_checkout_fields' );
1151
- // Our hooked in function - $fields is passed via the filter!
1152
- function sp_custom_override_checkout_fields( $fields ) {
1153
- $options = get_option( 'wccs_settings' );
1154
- if ( 1 == ($options['check']['wccs_opt_7_s'] ) )
1155
- unset($fields['shipping']['shipping_postcode']);
1156
- return $fields;
1157
- }
1158
- // =================== Shipping Country ======================
1159
- // Hook in
1160
- add_filter( 'woocommerce_checkout_fields' , 'sc_custom_override_checkout_fields' );
1161
- // Our hooked in function - $fields is passed via the filter!
1162
- function sc_custom_override_checkout_fields( $fields ) {
1163
- $options = get_option( 'wccs_settings' );
1164
- if ( 1 == ($options['check']['wccs_opt_8_s'] ) )
1165
- unset($fields['shipping']['shipping_country']);
1166
- return $fields;
1167
- }
1168
- // replace label and placeholder
1169
- function custom_replace_checkout_fieldssd( $fields ) {
1170
- $options = get_option( 'wccs_settings' );
1171
- if ( ! empty( $options['replace']['label_s7'] ) )
1172
- $fields['shipping']['shipping_country']['label'] = wpml_string_wccm($options['replace']['label_s7']);
1173
- return $fields;
1174
- }
1175
- add_filter( 'woocommerce_checkout_fields' , 'custom_replace_checkout_fieldssd' );
1176
- // Hook in
1177
- add_filter( 'woocommerce_checkout_fields' , 'ss_custom_override_checkout_fields' );
1178
- // Our hooked in function - $fields is passed via the filter!
1179
- function ss_custom_override_checkout_fields( $fields ) {
1180
- $options = get_option( 'wccs_settings' );
1181
- if ( 1 == ($options['check']['wccs_opt_9_s'] ) )
1182
- unset($fields['shipping']['shipping_state']);
1183
- return $fields;
1184
  }
 
 
1185
  function display_front_wccs() {
1186
  echo '<style type="text/css">
1187
- .wccs-field-class {
1188
- float:left;
1189
- width: 47%;
1190
- }
1191
- .wccs-field-class:nth-child(2n+2) {
1192
- padding-right: 3.4% !important;
1193
- }
1194
- .add_info_wccs {
1195
- clear: both;
1196
- }
1197
- </style>';
1198
  }
1199
- add_action('wp_head','display_front_wccs');
1200
-
1201
- add_filter( 'wp_feed_cache_transient_lifetime', create_function('$a', 'return 1800;') );
1202
-
1203
 
 
1204
  function wccm_woocommerce_delivery_notes_compat( $fields, $order ) {
1205
- $options = get_option( 'wccs_settings' );
1206
- $new_fields = array();
1207
-
1208
-
1209
- if ( count( $options['buttons'] ) > 0 ) :
1210
- $i = 0;
1211
- // Loop through each button
1212
- foreach ( $options['buttons'] as $btn ) :
1213
-
1214
-
1215
- if( get_post_meta( $order->id, ''.$btn['label'].'', true ) ) {
1216
- $new_fields[''.$btn['cow'].''] = array(
1217
- 'label' => ''.wpml_string_wccm($btn['label']).'',
1218
- 'value' => get_post_meta( $order->id, ''.$btn['label'].'', true )
1219
- );
1220
- }
1221
 
1222
- $i++;
1223
- endforeach;
1224
- endif;
 
 
 
 
 
 
 
 
1225
 
1226
- return array_merge( $fields, $new_fields );
1227
  }
1228
- add_filter( 'wcdn_order_info_fields', 'wccm_woocommerce_delivery_notes_compat', 10, 2 );
1229
 
 
1230
  function wpml_string_wccm($input) {
1231
-
1232
- if (function_exists( 'icl_t' )) {
1233
- return icl_t('WooCommerce Checkout Manager', ''.$input.'', ''.$input.'');
1234
- } else {
1235
- return $input;
1236
- }
1237
-
1238
  }
3
  Plugin Name: WooCommerce Checkout Manager
4
  Plugin URI: http://www.trottyzone.com/product/woocommerce-checkout-manager-pro
5
  Description: Manages WooCommerce Checkout fields
6
+ Version: 3.6.6
7
  Author: Ephrain Marchan
8
  Author URI: http://www.trottyzone.com
9
  License: GPLv2 or later
21
  along with this program; if not, write to the Free Software
22
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
  */
24
+
25
+ if ( ! defined( 'ABSPATH' ) ) die();
26
+
27
  load_plugin_textdomain('woocommerce-checkout-manager', false, dirname(plugin_basename(__FILE__)) . '/languages/');
28
+
29
+
30
+ register_activation_hook( __FILE__, 'wccs_install' );
31
+ add_filter( 'wp_feed_cache_transient_lifetime', create_function('$a', 'return 1800;') );
32
+ add_filter( 'wcdn_order_info_fields', 'wccm_woocommerce_delivery_notes_compat', 10, 2 );
33
+ add_action( 'admin_enqueue_scripts', 'wccs_scripts' );
34
+ add_action('woocommerce_after_checkout_billing_form', 'wccs_add_title');
35
+ add_action('woocommerce_after_checkout_billing_form', 'wccs_custom_checkout_field');
36
+ add_action('woocommerce_checkout_update_order_meta', 'wccs_custom_checkout_field_update_order_meta');
37
+ add_action('woocommerce_email_after_order_table', 'wccs_custom_style_checkout_email');
38
+ add_action('woocommerce_checkout_process', 'wccs_custom_checkout_field_process');
39
+ add_action('woocommerce_order_details_after_order_table', 'wccs_custom_checkout_details');
40
+ add_action('wp_head','display_front_wccs');
41
+
42
+
43
  function wccs_install() {
44
+
45
+ $defaults = array( 'buttons' => array(
46
+ array(
47
+ 'label' => __( 'Example Label', 'woocommerce-checkout-manager' ),
48
+ 'placeholder' => __( 'Example placeholder', 'woocommerce-checkout-manager' ),
49
+ 'cow' => __('myfld1', 'woocommerce-checkout-manager'),
50
+ 'option_a' => __('option 1', 'woocommerce-checkout-manager'),
51
+ 'option_b' => __('option 2', 'woocommerce-checkout-manager')
52
+ )
53
+ ),
54
+ 'checkness' => array(
55
+ 'checkbox1' => true,
56
+ 'checkbox12' => true
57
+ )
58
+ );
59
+
60
  add_option( 'wccs_settings', apply_filters( 'wccs_defaults', $defaults ) );
61
  }
62
+
63
+
64
+
65
+ if ( is_admin() ){
66
+ add_action( 'admin_menu', 'wccs_admin_menu' );
67
+ add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'wccs_admin_plugin_actions', -10);
68
+ add_action( 'admin_init', 'wccs_register_setting' );
69
+ } else {
70
+ wp_enqueue_script('jquery-ui-datepicker');
71
+ wp_enqueue_style( 'jquery-ui-style', (is_ssl()) ? 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' : 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
72
+ add_action('wp_enqueue_script', 'wccs_non_admin_scripts');
73
+ }
74
+
75
+ function wccs_non_admin_scripts() {
76
+ wp_enqueue_script('jquery-ui-datepicker');
77
+ wp_enqueue_style( 'jquery-ui-style', (is_ssl()) ? 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' : 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
78
+ }
79
+
80
+
81
  function wccs_admin_menu() {
82
+ add_submenu_page( 'woocommerce', __('Woocommerce Checkout Manager', 'woocommerce-checkout-manager'), __('WooCCM', 'woocommerce-checkout-manager'), 'manage_options', __FILE__ , 'wccs__options_page');
 
83
  }
84
+
85
+
86
  function wccs_register_setting() {
87
+ register_setting( 'wccs_options', 'wccs_settings', 'wccs_options_validate' );
88
  }
89
+
90
+
91
  function wccs__options_page() {
92
+ if ( !current_user_can('manage_options') ) {
93
+ wp_die( __('You do not have sufficient permissions to access this page.') );
 
 
94
  }
95
+
96
+
97
+ $hidden_field_name = 'mccs_submit_hidden';
98
  $options = get_option( 'wccs_settings' );
99
+
100
+
101
+ if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) {
102
+ update_option( 'wccs_settings', $options );
103
+
104
+ ?> <div class="updated"><p><strong><?php _e('settings saved.'); ?></strong></p></div>
105
+ <?php
106
  }
107
+
108
  echo '<div class="wrap">';
 
109
  echo '<div id="icon-themes" class="icon32"><br></div>';
110
+ echo '<h2>'. __( 'WooCommerce Checkout Manager', 'woocommerce-checkout-manager' ) .'';
111
+
 
112
  ?>
113
+
114
+ <!-- RSS FEED -->
115
  <div class="wooccm_feed">
116
+ <?php include_once( ABSPATH . WPINC . '/feed.php' );
117
+ $rss = fetch_feed( 'http://www.trottyzone.com/category/news-feed/' );
118
 
119
+ if ( ! is_wp_error( $rss ) ) :
 
120
 
121
+ // Figure out how many total items there are, but limit it to 5.
122
+ $maxitems = $rss->get_item_quantity( 1 );
123
+
124
+ // Build an array of all the items, starting with element 0 (first element).
125
+ $rss_items = $rss->get_items( 0, $maxitems );
126
 
127
+ endif;
128
+
129
+ if ( $maxitems == 0 ) :
130
+ else :
131
+
132
+ // Loop through each feed item and display each item as a hyperlink.
133
+ foreach ( $rss_items as $item ) : ?>
134
+
135
+ <a href="<?php echo esc_url( $item->get_permalink() ); ?>"
136
+ title="<?php printf( __( 'Posted %s', 'woocommerce-checkout-manager' ), $item->get_date('j F Y | g:i a') ); ?>">
137
+ <?php echo esc_html( $item->get_title() ); ?>
138
+ </a>
139
+
140
+ <?php endforeach;
141
+ endif; ?>
142
 
143
+ </div></h2>
144
+ <!-- FEED -->
145
+
146
+
147
+ <form name="form" method="post" action="options.php" id="frm1">
148
+ <?php settings_fields( 'wccs_options' );
149
+ $options = get_option( 'wccs_settings' ); ?>
150
+
151
+ <table class="widefat" border="1" style="margin-bottom:10px;">
152
+ <thead>
153
+ <tr>
154
+ <th><?php _e('Field Name', 'woocommerce-checkout-manager'); ?></th>
155
+ <th><?php _e('Remove Field Entirely', 'woocommerce-checkout-manager'); ?></th>
156
+ <th><?php _e('Remove Required Attribute', 'woocommerce-checkout-manager'); ?></th>
157
+ <th class="wccs_replace"><?php _e('Replace Label Name', 'woocommerce-checkout-manager'); ?></th>
158
+ <th class="wccs_replace"><?php _e('Replace Placeholder Name', 'woocommerce-checkout-manager'); ?></th>
159
+ </tr>
160
+ </thead>
161
+ <tbody>
162
+ <tr>
163
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
164
+ <td><strong><?php _e('Select All Check boxes in this Column', 'woocommerce-checkout-manager'); ?></strong></td>
165
+ <td><input name="wccs_settings[checkness][select_all_rm]" type="checkbox" id="select_all_rm" value="1" <?php echo (isset($options['checkness']['select_all_rm'])) ? "checked='checked'" : ""; ?> /></td>
166
+ <td><input name="wccs_settings[checkness][select_all_rq]" type="checkbox" id="select_all_rq" value="1" <?php echo (isset($options['checkness']['select_all_rq'])) ? "checked='checked'" : ""; ?> /></td>
167
+ <td></td>
168
+ <td></td>
169
+ </tr>
170
+ </tbody>
171
+ <tbody>
172
+ <tr>
173
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
174
+ <td><?php _e('First Name', 'woocommerce-checkout-manager'); ?></td>
175
+ <td><input name="wccs_settings[checkness][wccs_opt_1]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_1'])) ? "checked='checked'" : ""; ?> /></td>
176
+
177
+ <td><input name="wccs_settings[checkness][wccs_rq_1]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_1'])) ? "checked='checked'" : ""; ?> /></td>
178
+
179
+
180
+ <td><input type="text" name="wccs_settings[replace][label]"
181
+ value="<?php echo esc_attr( $options['replace']['label'] ); ?>" /></td>
182
+ <td><input type="text" name="wccs_settings[replace][placeholder]"
183
+ value="<?php echo esc_attr( $options['replace']['placeholder'] ); ?>" /></td>
184
+ </tr>
185
+ </tbody>
186
+ <tbody>
187
+ <tr>
188
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
189
+ <td><?php _e('Last Name', 'woocommerce-checkout-manager'); ?></td>
190
+ <td><input name="wccs_settings[checkness][wccs_opt_2]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_2'])) ? "checked='checked'" : ""; ?> /></td>
191
+ <td><input name="wccs_settings[checkness][wccs_rq_2]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_2'])) ? "checked='checked'" : ""; ?> /></td>
192
+ <td><input type="text" name="wccs_settings[replace][label1]"
193
+ value="<?php echo esc_attr( $options['replace']['label1'] ); ?>" /></td>
194
+ <td><input type="text" name="wccs_settings[replace][placeholder1]"
195
+ value="<?php echo esc_attr( $options['replace']['placeholder1'] ); ?>" /></td>
196
+ </tr>
197
+ </tbody>
198
+ <tbody>
199
+ <tr>
200
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
201
+ <td><?php _e('Country', 'woocommerce-checkout-manager'); ?></td>
202
+ <td><input name="wccs_settings[checkness][wccs_opt_8]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_8'])) ? "checked='checked'" : ""; ?> /></td>
203
+ <td><input name="wccs_settings[checkness][wccs_rq_8]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_8'])) ? "checked='checked'" : ""; ?> /></td>
204
+ <td><input type="text" name="wccs_settings[replace][label2]"
205
+ value="<?php echo esc_attr( $options['replace']['label2'] ); ?>" /></td>
206
+ <td></td>
207
+ </tr>
208
+ </tbody>
209
+ <tbody>
210
+ <tr>
211
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
212
+ <td><?php _e('Phone', 'woocommerce-checkout-manager'); ?></td>
213
+ <td><input name="wccs_settings[checkness][wccs_opt_10]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_10'])) ? "checked='checked'" : ""; ?> /></td>
214
+ <td><input name="wccs_settings[checkness][wccs_rq_10]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_10'])) ? "checked='checked'" : ""; ?> /></td>
215
+ <td><input type="text" name="wccs_settings[replace][label3]"
216
+ value="<?php echo esc_attr( $options['replace']['label3'] ); ?>" /></td>
217
+ <td><input type="text" name="wccs_settings[replace][placeholder3]"
218
+ value="<?php echo esc_attr( $options['replace']['placeholder3'] ); ?>" /></td>
219
+ </tr>
220
+ </tbody>
221
+ <tbody>
222
+ <tr>
223
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
224
+ <td><?php _e('Email', 'woocommerce-checkout-manager'); ?></td>
225
+ <td><input name="wccs_settings[checkness][wccs_opt_11]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_11'])) ? "checked='checked'" : ""; ?> /></td>
226
+ <td><input name="wccs_settings[checkness][wccs_rq_11]" type="checkbox" class="rq" value="1" <?php echo (isset($options['checkness']['wccs_rq_11'])) ? "checked='checked'" : ""; ?> /></td>
227
+ <td><input type="text" name="wccs_settings[replace][label4]"
228
+ value="<?php echo esc_attr( $options['replace']['label4'] ); ?>" /></td>
229
+ <td><input type="text" name="wccs_settings[replace][placeholder4]"
230
+ value="<?php echo esc_attr( $options['replace']['placeholder4'] ); ?>" /></td>
231
+ </tr>
232
+ </tbody>
233
+ <tbody>
234
+ <tr>
235
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
236
+ <td><?php _e('Company', 'woocommerce-checkout-manager'); ?></td>
237
+ <td><input name="wccs_settings[checkness][wccs_opt_3]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_3'])) ? "checked='checked'" : ""; ?> /></td>
238
+ <td></td>
239
+ <td><input type="text" name="wccs_settings[replace][label5]"
240
+ value="<?php echo esc_attr( $options['replace']['label5'] ); ?>" /></td>
241
+ <td><input type="text" name="wccs_settings[replace][placeholder5]"
242
+ value="<?php echo esc_attr( $options['replace']['placeholder5'] ); ?>" /></td>
243
+ </tr>
244
+ </tbody>
245
+ <tbody>
246
+ <tr>
247
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
248
+ <td><?php _e('Order Notes', 'woocommerce-checkout-manager'); ?></td>
249
+ <td><input name="wccs_settings[checkness][wccs_opt_12]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_12'])) ? "checked='checked'" : ""; ?> /></td>
250
+ <td></td>
251
+ <td><input type="text" name="wccs_settings[replace][label11]"
252
+ value="<?php echo esc_attr( $options['replace']['label11'] ); ?>" /></td>
253
+ <td><input type="text" name="wccs_settings[replace][placeholder11]"
254
+ value="<?php echo esc_attr( $options['replace']['placeholder11'] ); ?>" /></td>
255
+ </tr>
256
+ </tbody>
257
+ <tbody>
258
+ <tr>
259
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
260
+ <td><?php _e('Address 1', 'woocommerce-checkout-manager'); ?></td>
261
+ <td><input name="wccs_settings[checkness][wccs_opt_4]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_4'])) ? "checked='checked'" : ""; ?></td>
262
+ <td></td>
263
+ <td></td>
264
+ <td></td>
265
+ </tr>
266
+ </tbody>
267
+ <tbody>
268
+ <tr>
269
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
270
+ <td><?php _e('Address 2', 'woocommerce-checkout-manager'); ?></td>
271
+ <td><input name="wccs_settings[checkness][wccs_opt_5]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_5'])) ? "checked='checked'" : ""; ?> /></td>
272
+ <td></td>
273
+ <td></td>
274
+ <td></td>
275
+ </tr>
276
+ </tbody>
277
+ <tbody>
278
+ <tr>
279
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
280
+ <td><?php _e('City', 'woocommerce-checkout-manager'); ?></td>
281
+ <td><input name="wccs_settings[checkness][wccs_opt_6]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_6'])) ? "checked='checked'" : ""; ?> /></td>
282
+ <td></td>
283
+ <td></td>
284
+ <td></td>
285
+ </tr>
286
+ </tbody>
287
+ <tbody>
288
+ <tr>
289
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
290
+ <td><?php _e('Postal Code', 'woocommerce-checkout-manager'); ?></td>
291
+ <td><input name="wccs_settings[checkness][wccs_opt_7]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_7'])) ? "checked='checked'" : ""; ?> /></td>
292
+ <td></td>
293
+ <td></td>
294
+ <td></td>
295
+ </tr>
296
+ </tbody>
297
+ <tbody>
298
+ <tr>
299
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
300
+ <td><?php _e('State', 'woocommerce-checkout-manager'); ?></td>
301
+ <td><input name="wccs_settings[checkness][wccs_opt_9]" type="checkbox" class="rm" value="1" <?php echo (isset($options['checkness']['wccs_opt_9'])) ? "checked='checked'" : ""; ?> /></td>
302
+ <td></td>
303
+ <td></td>
304
+ <td></td>
305
+ </tr>
306
+ </tbody>
307
+ <?php submit_button( __( 'Save Changes', 'woocommerce-checkout-manager' ) ); ?>
308
+ <div class="wooccm_title"><?php _e('Billing Section', 'woocommerce-checkout-manager'); ?></div>
309
+ </table>
310
+ <table class="widefat" border="1" >
311
+ <thead>
312
+ <tr>
313
+ <th><?php _e('Field Name', 'woocommerce-checkout-manager'); ?></th>
314
+ <th><?php _e('Remove Field Entirely', 'woocommerce-checkout-manager'); ?></th>
315
+ <th><?php _e('Remove Required Attribute', 'woocommerce-checkout-manager'); ?></th>
316
+ <th class="wccs_replace"><?php _e('Replace Label Name', 'woocommerce-checkout-manager'); ?></th>
317
+ <th class="wccs_replace"><?php _e('Replace Placeholder Name', 'woocommerce-checkout-manager'); ?></th>
318
+ </tr>
319
+ </thead>
320
+ <tbody>
321
+ <tr>
322
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
323
+ <td><strong><?php _e('Select All Check boxes in this Column', 'woocommerce-checkout-manager'); ?></strong></td>
324
+ <td><input name="wccs_settings[check][select_all_rm_s]" type="checkbox" id="select_all_rm_s" value="1" <?php echo (isset($options['check']['select_all_rm_s'])) ? "checked='checked'" : ""; ?> /></td>
325
+ <td><input name="wccs_settings[check][select_all_rq_s]" type="checkbox" id="select_all_rq_s" value="1" <?php echo (isset($options['check']['select_all_rq_s'])) ? "checked='checked'" : ""; ?> /></td>
326
+ <td></td>
327
+ <td></td>
328
+ </tr>
329
+ </tbody>
330
+ <tbody>
331
+ <tr>
332
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
333
+ <td><?php _e('First Name', 'woocommerce-checkout-manager'); ?></td>
334
+ <td><input name="wccs_settings[check][wccs_opt_1_s]" type="checkbox" class="rm_s" value="1"
335
+ <?php echo (isset($options['check']['wccs_opt_1_s'])) ? "checked='checked'" : ""; ?> /></td>
336
+ <td><input name="wccs_settings[check][wccs_rq_1_s]" type="checkbox" class="rq_s" value="1" <?php echo (isset($options['check']['wccs_rq_1_s'])) ? "checked='checked'" : ""; ?> /></td>
337
+ <td><input type="text" name="wccs_settings[replace][label_s]"
338
+ value="<?php echo esc_attr( $options['replace']['label_s'] ); ?>" /></td>
339
+ <td><input type="text" name="wccs_settings[replace][placeholder_s]"
340
+ value="<?php echo esc_attr( $options['replace']['placeholder_s'] ); ?>" /></td>
341
+ </tr>
342
+ </tbody>
343
+ <tbody>
344
+ <tr>
345
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
346
+ <td><?php _e('Last Name', 'woocommerce-checkout-manager'); ?></td>
347
+ <td><input name="wccs_settings[check][wccs_opt_2_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_2_s'])) ? "checked='checked'" : ""; ?> /></td>
348
+ <td><input name="wccs_settings[check][wccs_rq_2_s]" type="checkbox" class="rq_s" value="1" <?php echo (isset($options['check']['wccs_rq_2_s'])) ? "checked='checked'" : ""; ?> /></td>
349
+ <td><input type="text" name="wccs_settings[replace][label_s1]"
350
+ value="<?php echo esc_attr( $options['replace']['label_s1'] ); ?>" /></td>
351
+ <td><input type="text" name="wccs_settings[replace][placeholder_s1]"
352
+ value="<?php echo esc_attr( $options['replace']['placeholder_s1'] ); ?>" /></td>
353
+ </tr>
354
+ </tbody>
355
+ <tbody>
356
+ <tr>
357
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
358
+ <td><?php _e('Company', 'woocommerce-checkout-manager'); ?></td>
359
+ <td><input name="wccs_settings[check][wccs_opt_3_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_3_s'])) ? "checked='checked'" : ""; ?> /></td>
360
+ <td></td>
361
+ <td><input type="text" name="wccs_settings[replace][label_s2]"
362
+ value="<?php echo esc_attr( $options['replace']['label_s2'] ); ?>" /></td>
363
+ <td><input type="text" name="wccs_settings[replace][placeholder_s2]"
364
+ value="<?php echo esc_attr( $options['replace']['placeholder_s2'] ); ?>" /></td>
365
+ </tr>
366
+ </tbody>
367
+ <tbody>
368
+ <tr>
369
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
370
+ <td><?php _e('Country', 'woocommerce-checkout-manager'); ?></td>
371
+ <td><input name="wccs_settings[check][wccs_opt_8_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_8_s'])) ? "checked='checked'" : ""; ?> /></td>
372
+ <td></td>
373
+ <td><input type="text" name="wccs_settings[replace][label_s7]"
374
+ value="<?php echo esc_attr( $options['replace']['label_s7'] ); ?>" /></td>
375
+ <td></td>
376
+ </tr>
377
+ </tbody>
378
+ <tbody>
379
+ <tr>
380
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
381
+ <td><?php _e('Address 1', 'woocommerce-checkout-manager'); ?></td>
382
+ <td><input name="wccs_settings[check][wccs_opt_4_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_4_s'])) ? "checked='checked'" : ""; ?></td>
383
+ <td></td>
384
+ <td></td>
385
+ <td></td>
386
+ </tr>
387
+ </tbody>
388
+ <tbody>
389
+ <tr>
390
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
391
+ <td><?php _e('Address 2', 'woocommerce-checkout-manager'); ?></td>
392
+ <td><input name="wccs_settings[check][wccs_opt_5_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_5_s'])) ? "checked='checked'" : ""; ?> /></td>
393
+ <td></td>
394
+ <td></td>
395
+ <td></td>
396
+ </tr>
397
+ </tbody>
398
+ <tbody>
399
+ <tr>
400
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
401
+ <td><?php _e('City', 'woocommerce-checkout-manager'); ?></td>
402
+ <td><input name="wccs_settings[check][wccs_opt_6_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_6_s'])) ? "checked='checked'" : ""; ?> /></td>
403
+ <td></td>
404
+ <td></td>
405
+ <td></td>
406
+ </tr>
407
+ </tbody>
408
+ <tbody>
409
+ <tr>
410
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
411
+ <td><?php _e('Postal Code', 'woocommerce-checkout-manager'); ?></td>
412
+ <td><input name="wccs_settings[check][wccs_opt_7_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_7_s'])) ? "checked='checked'" : ""; ?> /></td>
413
+ <td></td>
414
+ <td></td>
415
+ <td></td>
416
+ </tr>
417
+ </tbody>
418
+ <tbody>
419
+ <tr>
420
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
421
+ <td><?php _e('State', 'woocommerce-checkout-manager'); ?></td>
422
+ <td><input name="wccs_settings[check][wccs_opt_9_s]" type="checkbox" class="rm_s" value="1" <?php echo (isset($options['check']['wccs_opt_9_s'])) ? "checked='checked'" : ""; ?> /></td>
423
+ <td></td>
424
+ <td></td>
425
+ <td></td>
426
+ </tr>
427
+ </tbody>
428
+ <div class="wooccm_title"><?php _e('Shipping Section', 'woocommerce-checkout-manager'); ?></div>
429
+ </table>
430
+
431
+ <div style="padding:5px 10px;font-weight:700;color:green;" class="clear_dwccm">
432
 
433
+
434
+ <div class="updated clear_wccm data">
435
+ <div class="clear_wccm title">
436
+ <a href="http://www.trottyzone.com/product/woocommerce-checkout-manager-pro/"><?php _e('TRY THE PRO VERSION', 'woocommerce-checkout-manager'); ?></a><br /><span class="small"><?php _e('includes these field types', 'woocommerce-checkout-manager'); ?></span> &#8594;
437
+ </div>
438
+ <ul>
439
+ <li><?php _e('Text Area', 'woocommerce-checkout-manager'); ?></li>
440
+ <li><?php _e('Password', 'woocommerce-checkout-manager'); ?></li>
441
+ <li><?php _e('Mult-Select', 'woocommerce-checkout-manager'); ?></li>
442
+ </ul>
443
+ <ul>
444
+ <li><?php _e('Radio Button (Unlimited Options)', 'woocommerce-checkout-manager'); ?></li>
445
+ <li><?php _e('Select Options (Unlimited Options)', 'woocommerce-checkout-manager'); ?></li>
446
+ <li><?php _e('Time Picker', 'woocommerce-checkout-manager'); ?></li>
447
+ </ul>
448
+ <ul>
449
+ <li><?php _e('Text/ Html Swapper', 'woocommerce-checkout-manager'); ?></li>
450
+ <li><?php _e('Color Picker', 'woocommerce-checkout-manager'); ?></li>
451
+ <li><?php _e('Heading', 'woocommerce-checkout-manager'); ?></li>
452
+ </ul>
453
+ <ul>
454
+ <li><?php _e('Check Box (Put your own options)', 'woocommerce-checkout-manager'); ?></li>
455
+ <li><strong><a href="http://www.trottyzone.com/product/woocommerce-checkout-manager-pro/"><?php _e('more features. . .', 'woocommerce-checkout-manager'); ?></a></strong></li>
456
+ </ul>
457
+ </div>
458
+ </div>
459
+
460
+ <div class="wooccm_title" ><?php _e('Add New Field Section', 'woocommerce-checkout-manager'); ?></div>
461
+ <table class="widefat" border="1" >
462
+ <thead>
463
+ <tr>
464
+ <th><?php _e('Enable Title - Additional information', 'atc-menu'); ?></th>
465
+ <th><input style="float:left;" name="wccs_settings[checkness][checkbox12]" type="checkbox" value="true" <?php echo (isset($options['checkness']['checkbox12'])) ? "checked='checked'": ""; ?> /></th>
466
+ <th><?php _e('Checkout Page', 'atc-menu'); ?></th>
467
+ <th><input style="float:left;" name="wccs_settings[checkness][checkbox1]" type="checkbox" value="true" <?php echo (isset($options['checkness']['checkbox1'])) ? "checked='checked'": ""; ?> /></th>
468
+ <th><?php _e('Checkout Details and Email Receipt', 'atc-menu'); ?></th>
469
+ </tr>
470
+ </thead>
471
+ </table>
472
+
473
+ <table class="widefat wccs-table" border="1">
474
+ <thead>
475
+ <tr>
476
+ <th style="width:3%;" class="wccs-order" title="<?php esc_attr_e( 'Change order' , 'woocommerce-checkout-manager' ); ?>">#</th>
477
+ <th><?php _e('Label' , 'woocommerce-checkout-manager' ); ?></th>
478
+ <th><?php _e('Placeholder' , 'woocommerce-checkout-manager' ); ?></th>
479
+ <th><?php _e('Option A' , 'woocommerce-checkout-manager' ); ?></th>
480
+ <th><?php _e('Options B' , 'woocommerce-checkout-manager' ); ?></th>
481
+ <th width="5%"><?php _e('Choose Type' , 'woocommerce-checkout-manager' ); ?></th>
482
+ <th width="5%"><?php _e('Abbreviation' , 'woocommerce-checkout-manager' ); ?></th>
483
+ <th width="5%"><?php _e('Required' , 'woocommerce-checkout-manager' ); ?></th>
484
+ <th style="text-align:center;" scope="col" title="<?php esc_attr_e( 'Remove button', 'woocommerce-checkout-manager' ); ?>">X</th>
485
+ </tr>
486
+ </thead>
487
+ <tbody>
488
+
489
+ <?php if ( isset ( $options['buttons'] ) ) :
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
490
  for ( $i = 0; $i < count( $options['buttons'] ); $i++ ) :
491
  if ( ! isset( $options['buttons'][$i] ) )
492
+ break; ?>
493
+
494
+ <tr valign="top" class="wccs-row">
495
+ <td class="wccs-order" title="<?php esc_attr_e( 'Change order', 'woocommerce-checkout-manager' ); ?>"><?php echo $i + 1; ?></td>
496
+
497
+ <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][label]"
498
+ value="<?php echo esc_attr($options['buttons'][$i]['label']); ?>" /></td>
499
+
500
+ <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][placeholder]"
501
+ value="<?php echo esc_attr($options['buttons'][$i]['placeholder']); ?>" /></td>
502
+
503
+ <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][option_a]"
504
+ value="<?php echo esc_attr( $options['buttons'][$i]['option_a'] ); ?>" /></td>
505
+
506
+ <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][option_b]"
507
+ value="<?php echo esc_attr( $options['buttons'][$i]['option_b'] ); ?>" /></td>
508
+
509
+ <td>
510
+ <select name="wccs_settings[buttons][<?php echo $i; ?>][type]" > <!--Call run() function-->
511
+ <option value="text" <?php selected( $options['buttons'][$i]['type'], 'text' ); ?>>Text Input</option>
512
+ <option value="select" <?php selected( $options['buttons'][$i]['type'], 'select' ); ?>>Select Options</option>
513
+ <option value="date" <?php selected( $options['buttons'][$i]['type'], 'date' ); ?>>Date Picker</option>
514
+ <option value="checkbox" <?php selected( $options['buttons'][$i]['type'], 'checkbox' ); ?>>Checkbox (1, 0)</option>
515
+ </select>
516
+ </td>
517
+
518
+ <td><input type="text" maxlength="10" name="wccs_settings[buttons][<?php echo $i; ?>][cow]"
519
+ value="<?php echo esc_attr($options['buttons'][$i]['cow']); ?>" readonly="readonly" /></td>
520
+
521
+ <td style="text-align:center;"><input style="float:none;" name="wccs_settings[buttons][<?php echo $i; ?>][checkbox]" type="checkbox" value="true" <?php echo (isset($options['buttons'][$i]['checkbox'])) ? "checked='checked'": ""; ?> /></td>
522
+ <td class="wccs-remove"><a class="wccs-remove-button" href="javascript:;" title="<?php esc_attr_e( 'Remove Field' , 'woocommerce-checkout-manager' ); ?>">&times;</a></td>
523
+ </tr>
524
+
525
+ <?php endfor; endif; ?>
526
+
527
+ <!-- Empty -->
528
+ <?php $i = 999; ?>
529
+ <tr valign="top" class="wccs-clone" >
530
+ <td class="wccs-order" title="<?php esc_attr_e( 'Change order' , 'woocommerce-checkout-manager' ); ?>"><?php echo $i; ?></td>
531
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
532
+ <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][label]"
533
+ title="<?php esc_attr_e( 'Label of the New Field', 'woocommerce-checkout-manager' ); ?>" value="" /></td>
534
+ <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][placeholder]"
535
+ title="<?php esc_attr_e( 'Placeholder - Preview of Data to Input', 'woocommerce-checkout-manager' ); ?>" value="" /></td>
536
+ <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][option_a]"
537
+ title="<?php esc_attr_e( 'Insert Option A', 'woocommerce-checkout-manager' ); ?>" value="" /></td>
538
+ <td><input type="text" name="wccs_settings[buttons][<?php echo $i; ?>][option_b]"
539
+ title="<?php esc_attr_e( 'Insert Option B', 'woocommerce-checkout-manager' ); ?>" value="" /></td>
540
+ <td>
541
+ <select name="wccs_settings[buttons][<?php echo $i; ?>][type]" > <!--Call run() function-->
542
+ <option value="text" >Text Input</option>
543
+ <option value="select" >Select Options</option>
544
+ <option value="date" >Date Picker</option>
545
+ <option value="checkbox" >Checkbox (1, 0)</option>
546
+ </select>
547
+ </td>
548
+ <td><input type="text" maxlength="5" name="wccs_settings[buttons][<?php echo $i; ?>][cow]"
549
+ title="<?php esc_attr_e( 'Abbreviation (No spaces)', 'woocommerce-checkout-manager' ); ?>" value="" readonly="readonly" /></td>
550
+ <td style="text-align:center;"><input style="float:none;" name="wccs_settings[buttons][<?php echo $i; ?>][checkbox]" type="checkbox"
551
+ title="<?php esc_attr_e( 'Add/Remove Required Attribute', 'woocommerce-checkout-manager' ); ?>" value="" /></td>
552
+ <td class="wccs-remove"><a class="wccs-remove-button" href="javascript:;" title="<?php esc_attr_e( 'Remove Field' , 'woocommerce-checkout-manager' ); ?>">&times;</a></td>
553
+ </tr>
554
+ </tbody>
555
+ </table>
556
+
557
+ <div class="wccs-table-footer">
558
+ <a href="javascript:;" id="wccs-add-button" class="button-secondary"><?php _e( '+ Add New Field' , 'woocommerce-checkout-manager' ); ?></a>
559
+ </div>
560
  </form>
561
+
562
+ <?php }
563
+
564
+
565
+
566
+
567
  // Build array of links for rendering in installed plugins list
568
  function wccs_admin_plugin_actions($links) {
569
  $wccs_plugin_links = array(
570
+ '<a href="admin.php?page=woocommerce-checkout-manager/woocommerce-checkout-manager.php">'.__('Settings').'</a>',
571
+ '<a href="http://www.trottyzone.com/product/woocommerce-checkout-manager-pro/">'.__('Pro Version').'</a>',
572
  );
573
  return array_merge( $wccs_plugin_links, $links );
574
  }
575
+
576
  function wccs_scripts( $hook_suffix ) {
577
+ if ( $hook_suffix == 'woocommerce_page_woocommerce-checkout-manager/woocommerce-checkout-manager' ) {
578
+ wp_enqueue_style( 'wooccm-style', plugins_url( 'style_wccs.css', __FILE__ ) );
579
+ wp_enqueue_script( 'script_wccs', plugins_url( 'script_wccs.js', __FILE__ ), array( 'jquery' ), '1.2' );
580
  if(!wp_script_is('jquery-ui-sortable', 'queue')){
581
  wp_enqueue_script('jquery-ui-sortable');
582
+ }
583
  }
584
  }
585
+
586
+
587
+ function wccs_override_checkout_fields($fields) {
 
 
 
 
 
 
 
588
  $options = get_option( 'wccs_settings' );
589
+
590
+ if ( 1 == ($options['checkness']['wccs_opt_1'] ) ) {
591
+ unset($fields['billing']['billing_first_name']);
592
  }
593
+ if ( ! empty( $options['replace']['placeholder'] ) ) {
 
 
 
 
594
  $fields['billing']['billing_first_name']['placeholder'] = wpml_string_wccm($options['replace']['placeholder']);
 
595
  }
596
+ if ( ! empty( $options['replace']['label'] ) ) {
 
 
 
597
  $fields['billing']['billing_first_name']['label'] = wpml_string_wccm($options['replace']['label']);
 
598
  }
599
+ if ( 1 == ($options['checkness']['wccs_opt_2'] ) ) {
600
+ unset($fields['billing']['billing_last_name']);
601
+ }
602
+ if ( ! empty( $options['replace']['placeholder1'] ) ) {
603
+ $fields['billing']['billing_last_name']['placeholder'] = wpml_string_wccm($options['replace']['placeholder1']);
 
 
604
  }
605
+ if ( ! empty( $options['replace']['label1'] ) ) {
606
+ $fields['billing']['billing_last_name']['label'] = wpml_string_wccm($options['replace']['label1']);
 
 
 
 
607
  }
608
+ if ( 1 == ($options['checkness']['wccs_opt_3'] ) ) {
609
+ unset($fields['billing']['billing_company']);
 
 
 
 
 
610
  }
611
+ if ( ! empty( $options['replace']['placeholder2'] ) ) {
612
+ $fields['billing']['billing_company']['placeholder'] = wpml_string_wccm($options['replace']['placeholder2']);
 
 
 
 
613
  }
614
+ if ( ! empty( $options['replace']['label5'] ) ) {
615
+ $fields['billing']['billing_company']['label'] = wpml_string_wccm($options['replace']['label5']);
 
 
 
 
 
616
  }
617
+ if ( 1 == ($options['checkness']['wccs_opt_4'] ) ) {
618
+ unset($fields['billing']['billing_address_1']);
 
 
 
 
 
619
  }
620
+ if ( 1 == ($options['checkness']['wccs_opt_5'] ) ) {
621
+ unset($fields['billing']['billing_address_2']);
 
 
 
 
622
  }
623
+ if ( 1 == ($options['checkness']['wccs_opt_6'] ) ) {
624
+ unset($fields['billing']['billing_city']);
 
 
 
 
 
625
  }
626
+ if ( 1 == ($options['checkness']['wccs_opt_7'] ) ) {
627
+ unset($fields['billing']['billing_postcode']);
 
 
 
 
 
 
 
 
 
 
 
 
 
628
  }
629
+ if ( 1 == ($options['checkness']['wccs_opt_8'] ) ) {
630
+ unset($fields['billing']['billing_country']);
 
 
 
 
 
631
  }
632
+ if ( 1 == ($options['checkness']['wccs_opt_9'] ) ) {
633
+ unset($fields9['billing']['billing_state']);
 
 
 
 
 
634
  }
635
+ if ( 1 == ($options['checkness']['wccs_opt_10'] ) ) {
636
+ unset($fields10['billing']['billing_phone']);
 
 
 
 
637
  }
638
+ if ( ! empty( $options['replace']['label2'] ) ) {
 
 
 
639
  $fields['billing']['billing_country']['label'] = wpml_string_wccm($options['replace']['label2']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
  }
641
+ if ( ! empty( $options['replace']['placeholder3'] ) ) {
 
 
 
 
642
  $fields['billing']['billing_phone']['placeholder'] = wpml_string_wccm($options['replace']['placeholder3']);
 
643
  }
644
+ if ( ! empty( $options['replace']['label3'] ) ) {
 
 
 
645
  $fields['billing']['billing_phone']['label'] = wpml_string_wccm($options['replace']['label3']);
 
646
  }
647
+ if ( 1 == ($options['checkness']['wccs_opt_11'] ) ) {
648
+ unset($fields11['billing']['billing_email']);
 
 
 
 
 
649
  }
650
+ if ( ! empty( $options['replace']['placeholder4'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
651
  $fields['billing']['billing_email']['placeholder'] = wpml_string_wccm($options['replace']['placeholder4']);
 
652
  }
653
+ if ( ! empty( $options['replace']['label4'] ) ) {
 
 
 
654
  $fields['billing']['billing_email']['label'] = wpml_string_wccm($options['replace']['label4']);
 
655
  }
656
+ if ( 1 == ($options['checkness']['wccs_opt_12'] ) ) {
657
+ unset($fields12['order']['order_comments']);
 
 
 
 
 
658
  }
659
+ if ( ! empty( $options['replace']['placeholder11'] ) ) {
 
 
 
 
660
  $fields['order']['order_comments']['placeholder'] = wpml_string_wccm($options['replace']['placeholder11']);
 
661
  }
662
+ if ( ! empty( $options['replace']['label11'] ) ) {
 
 
 
663
  $fields['order']['order_comments']['label'] = wpml_string_wccm($options['replace']['label11']);
 
664
  }
665
+ if ( 1 == ($options['check']['wccs_opt_1_s'] ) ) {
666
+ unset($fields1['shipping']['shipping_first_name']);
667
+ }
668
+ if ( ! empty( $options['replace']['placeholder_s'] ) ) {
669
+ $fields['shipping']['shipping_first_name']['placeholder'] = wpml_string_wccm($options['replace']['placeholder_s']);
670
+ }
671
+ if ( ! empty( $options['replace']['label_s'] ) ) {
672
+ $fields['shipping']['shipping_first_name']['label'] = wpml_string_wccm($options['replace']['label_s']);
673
+ }
674
+ if ( 1 == ($options['check']['wccs_opt_2_s'] ) ) {
675
+ unset($fields2['shipping']['shipping_last_name']);
676
+ }
677
+ if ( ! empty( $options['replace']['placeholder_s1'] ) ) {
678
+ $fields['shipping']['shipping_last_name']['placeholder'] = wpml_string_wccm($options['replace']['placeholder_s1']);
679
+ }
680
+ if ( ! empty( $options['replace']['label_s1'] ) ) {
681
+ $fields['shipping']['shipping_last_name']['label'] = wpml_string_wccm($options['replace']['label_s1']);
682
+ }
683
+ if ( 1 == ($options['check']['wccs_opt_3_s'] ) ) {
684
+ unset($fields3['shipping']['shipping_company']);
685
+ }
686
+ if ( ! empty( $options['replace']['placeholder_s2'] ) ) {
687
+ $fields['shipping']['shipping_company']['placeholder'] = wpml_string_wccm($options['replace']['placeholder_s2']);
688
+ }
689
+ if ( ! empty( $options['replace']['label_s2'] ) ) {
690
+ $fields['shipping']['shipping_company']['label'] = wpml_string_wccm($options['replace']['label_s2']);
691
+ }
692
+ if ( 1 == ($options['check']['wccs_opt_4_s'] ) ) {
693
+ unset($fields['shipping']['shipping_address_1']);
694
+ }
695
+ if ( 1 == ($options['check']['wccs_opt_5_s'] ) ) {
696
+ unset($fields['shipping']['shipping_address_2']);
697
+ }
698
+ if ( 1 == ($options['check']['wccs_opt_6_s'] ) ) {
699
+ unset($fields['shipping']['shipping_city']);
700
+ }
701
+ if ( 1 == ($options['check']['wccs_opt_7_s'] ) ) {
702
+ unset($fields['shipping']['shipping_postcode']);
703
+ }
704
+ if ( 1 == ($options['check']['wccs_opt_8_s'] ) ) {
705
+ unset($fields['shipping']['shipping_country']);
706
+ }
707
+ if ( ! empty( $options['replace']['label_s7'] ) ) {
708
+ $fields['shipping']['shipping_country']['label'] = wpml_string_wccm($options['replace']['label_s7']);
709
+ }
710
+ if ( 1 == ($options['check']['wccs_opt_9_s'] ) ) {
711
+ unset($fields['shipping']['shipping_state']);
712
+ }
713
+ return $fields;
714
+ }
715
+ add_filter( 'woocommerce_checkout_fields' , 'wccs_override_checkout_fields' );
716
+
717
+
718
+
719
+
720
+
721
+ function wccs_override_required_fields( $address_fields ) {
722
+ $options = get_option( 'wccs_settings' );
723
+ if ( 1 == ($options['checkness']['wccs_rq_2'] ) ) {
724
+ $address_fields['billing_last_name']['required'] = false;
725
+ }
726
+ if ( 1 == ($options['checkness']['wccs_rq_1'] ) ) {
727
+ $address_fields['billing_first_name']['required'] = false;
728
+ }
729
+ if ( 1 == ($options['checkness']['wccs_rq_8'] ) ) {
730
+ $address_fields['billing_country']['required'] = false;
731
+ }
732
+ if ( 1 == ($options['checkness']['wccs_rq_10'] ) ) {
733
+ $address_fields['billing_phone']['required'] = false;
734
+ }
735
+ if ( 1 == ($options['checkness']['wccs_rq_11'] ) ) {
736
+ $address_fields['billing_email']['required'] = false;
737
+ }
738
+ return $address_fields;
739
+ }
740
+ add_filter( 'woocommerce_billing_fields', 'wccs_override_required_fields', 10, 1 );
741
+
742
+
743
+
744
+ function wccs_shipping_required_fields( $address_fields ) {
745
+ $options = get_option( 'wccs_settings' );
746
+ if ( 1 == ($options['check']['wccs_rq_1_s'] ) ) {
747
+ $address_fields['shipping_first_name']['required'] = false;
748
+ }
749
+ if ( 1 == ($options['check']['wccs_rq_2_s'] ) ) {
750
+ $address_fields['shipping_last_name']['required'] = false;
751
+ }
752
+ return $address_fields;
753
+ }
754
+ add_filter( 'woocommerce_shipping_fields', 'wccs_shipping_required_fields', 10, 1 );
755
+
756
+
757
+
758
+
759
+
760
  function wccs_add_title() {
761
  $options = get_option( 'wccs_settings' );
762
+ if (true == ($options['checkness']['checkbox12']) )
763
+ echo '<div class="add_info_wccs"><br><h3>' . __( 'Additional information', 'woocommerce-checkout-manager' ) . '</h3></div>';
764
  }
765
+
766
+
767
+
768
  // =============== Add the field to the checkout =====================
769
  function wccs_custom_checkout_field( $checkout ) {
770
  $options = get_option( 'wccs_settings' );
771
+ if ( count( $options['buttons'] ) > 0 ) :
772
+ foreach ( $options['buttons'] as $btn ) :
773
+
774
+ if ( ! empty( $btn['label'] ) && ($btn['type'] == 'text') ) {
775
+ woocommerce_form_field( ''.$btn['cow'].'' , array(
776
+ 'type' => 'text',
777
+ 'class' => array('wccs-field-class wccs-form-row-wide'),
778
+ 'label' => wpml_string_wccm(''.$btn['label'].''),
779
+ 'required' => $btn['checkbox'],
780
+ 'placeholder' => wpml_string_wccm(''.$btn['placeholder'].''),
781
+ ), $checkout->get_value( ''.$btn['cow'].'' ));
782
+ }
783
+ if ( ! empty( $btn['label'] ) && ($btn['type'] == 'select') ) {
784
+ woocommerce_form_field( ''.$btn['cow'].'' , array(
785
+ 'type' => 'select',
786
+ 'class' => array('wccs-field-class wccs-form-row-wide'),
787
+ 'label' => wpml_string_wccm(''.$btn['label'].''),
788
+ 'options' => array(
789
+ '' => __('Select below', 'woocommerce-checkout-manager' ),
790
+ ''.wpml_string_wccm(''.$btn['option_a'].'').'' => ''.wpml_string_wccm(''.$btn['option_a'].'').'',
791
+ ''.wpml_string_wccm(''.$btn['option_b'].'').'' => ''.wpml_string_wccm(''.$btn['option_b'].'').''
792
+ ),
793
+ 'required' => $btn['checkbox'],
794
+ 'placeholder' => wpml_string_wccm(''.$btn['placeholder'].''),
795
+ ), $checkout->get_value( ''.$btn['cow'].'' ));
796
+ }
797
+ if ( ! empty( $btn['label'] ) && ($btn['type'] == 'date') ) {
798
+ echo '<script type="text/javascript">
799
+ jQuery(document).ready(function() {
800
+ jQuery(".MyDate-'.$btn['cow'].' #'.$btn['cow'].'").datepicker({
801
+ dateFormat : "dd-mm-yy"
802
+ });
803
+ });
804
+ </script>';
805
+ woocommerce_form_field( ''.$btn['cow'].'' , array(
806
+ 'type' => 'text',
807
+ 'class' => array('wccs-field-class MyDate-'.$btn['cow'].' wccs-form-row-wide'),
808
+ 'label' => wpml_string_wccm(''.$btn['label'].''),
809
+ 'required' => $btn['checkbox'],
810
+ 'placeholder' => wpml_string_wccm(''.$btn['placeholder'].''),
811
+ ), $checkout->get_value( ''.$btn['cow'].'' ));
812
+ }
813
+ if ( ! empty( $btn['label'] ) && ($btn['type'] == 'checkbox') ) {
814
+ woocommerce_form_field( ''.$btn['cow'].'' , array(
815
+ 'type' => 'checkbox',
816
+ 'class' => array('wccs-field-class wccs-form-row-wide'),
817
+ 'label' => wpml_string_wccm(''.$btn['label'].''),
818
+ 'required' => $btn['checkbox'],
819
+ 'placeholder' => wpml_string_wccm(''.$btn['placeholder'].''),
820
+ ), $checkout->get_value( ''.$btn['cow'].'' ));
821
+ }
822
+ endforeach;
 
 
 
 
 
 
 
 
 
 
823
  endif;
824
  }
825
+
826
+
827
  // ============================== Update the order meta with field value ==============================
828
  function wccs_custom_checkout_field_update_order_meta( $order_id ) {
829
  $options = get_option( 'wccs_settings' );
830
+ if ( count( $options['buttons'] ) > 0 ) :
831
+ foreach ( $options['buttons'] as $btn ) :
832
+ if ( ! empty( $btn['cow'] ) )
833
+ if ( $_POST[ ''.$btn['cow'].'' ])
834
+ update_post_meta( $order_id, ''.$btn['cow'].'' , esc_attr( $_POST[ ''.$btn['cow'].'' ] ));
835
+ endforeach;
836
+ endif;
 
 
 
 
837
  }
838
+
839
  // =============== Add to email (working) =====================
840
  add_filter('woocommerce_email_order_meta_keys', 'wccs_custom_checkout_field_order_meta_keys');
841
  function wccs_custom_checkout_field_order_meta_keys( $keys ) {
842
  $options = get_option( 'wccs_settings' );
843
+ if ( count( $options['buttons'] ) > 0 ) :
844
+ foreach ( $options['buttons'] as $btn ) :
845
+ if ( ! empty( $btn['cow'] ) )
846
+ $keys[''.wpml_string_wccm($btn['label']).''] = ''.$btn['cow'].'';
847
+ endforeach;
848
+ return $keys;
849
+ endif;
 
 
 
 
850
  }
851
+
852
+
853
  // ================ Style the Email =======================
 
854
  function wccs_custom_style_checkout_email() {
855
  $options = get_option( 'wccs_settings' );
856
+ if (true == ($options['checkness']['checkbox1']) )
857
+ echo '<h2>' . __( 'Additional information', 'woocommerce-checkout-manager' ) . '</h2>';
858
  }
859
+
860
+
861
  // ============== Process the checkout (if needed activate) ==================
862
  function wccs_custom_checkout_field_process() {
863
+ global $woocommerce;
864
  $options = get_option( 'wccs_settings' );
865
+ if ( count( $options['buttons'] ) > 0 ) :
866
+ foreach ( $options['buttons'] as $btn ) :
867
+ if ( (!$_POST[ ''.$btn['cow'].'' ] ) && (true == ($btn['checkbox']) ) )
868
+ $woocommerce->add_error( '<strong>'.$btn['label'].'</strong> '. __('is a required field', 'woocommerce-checkout-manager' ) . ' ');
869
+ endforeach;
870
+ endif;
 
 
 
 
 
 
 
 
 
 
 
871
  }
872
+
873
  function wccs_options_validate( $input ) {
874
  $options = get_option( 'wccs_settings' );
875
+
876
  foreach( $input['buttons'] as $i => $btn ) :
877
 
878
+ if( function_exists( 'icl_register_string' ) ) {
879
+
880
+ icl_register_string('WooCommerce Checkout Manager', ''.$btn['label'].'', ''.$btn['label'].'');
881
+ icl_register_string('WooCommerce Checkout Manager', ''.$btn['placeholder'].'', ''.$btn['placeholder'].'');
882
+ icl_register_string('WooCommerce Checkout Manager', ''.$btn['option_a'].'', ''.$btn['option_a'].'');
883
+ icl_register_string('WooCommerce Checkout Manager', ''.$btn['option_b'].'', ''.$btn['option_b'].'');
884
+
885
+ }
886
+
887
+ if( empty( $btn['cow'] ) && empty( $btn['label'] ) && empty( $btn['placeholder'] ) ) {
888
+ unset( $input['buttons'][$i], $btn );
889
+ }
890
+
891
+ if ( empty( $btn['cow'] ) && (!empty( $btn['label'] ) || !empty( $btn['placeholder'] )) ) {
892
+ $newNum = $i + 1;
893
+ $input['buttons'][$i]['cow'] = 'myfield'.$newNum.'';
894
+ }
895
+
896
  endforeach;
897
 
898
+
899
  foreach( $input['replace'] as $type => $value ) :
900
  if( function_exists( 'icl_register_string' ) ) {
901
  if(!empty($value) && $value!=''){
902
  icl_register_string('WooCommerce Checkout Manager', ''.$value.'', ''.$value.'');
903
  }
904
  }
 
 
905
  endforeach;
906
 
907
+
908
 
909
  $input['buttons'] = array_values( $input['buttons'] );
910
  return $input;
911
  }
912
+
913
+
914
+
915
  function wccs_custom_checkout_details( $order_id ) {
916
  $options = get_option( 'wccs_settings' );
917
+
918
+ if (true == ($options['checkness']['checkbox1']) ) {
919
+ echo '<h2>' . __( 'Additional information', 'woocommerce-checkout-manager' ) . '</h2>';
920
+ }
921
+
922
+ if ( count( $options['buttons'] ) > 0 ) :
923
+ foreach ( $options['buttons'] as $btn ) :
924
+ echo '<dt>'.wpml_string_wccm($btn['label']).':</dt><dd>'.get_post_meta( $order_id->id , ''.$btn['cow'].'', true).'</dd>';
925
+ endforeach;
926
+ endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
927
  }
928
+
929
+
930
  function display_front_wccs() {
931
  echo '<style type="text/css">
932
+ .wccs-field-class {
933
+ float:left;
934
+ width: 47%;
935
+ }
936
+ .wccs-field-class:nth-child(2n+2) {
937
+ padding-right: 3.4% !important;
938
+ }
939
+ .add_info_wccs {
940
+ clear: both;
941
+ }
942
+ </style>';
943
  }
 
 
 
 
944
 
945
+ // =============== Make compatible with WooCommerce Delivery Notes ===========
946
  function wccm_woocommerce_delivery_notes_compat( $fields, $order ) {
947
+ $options = get_option( 'wccs_settings' );
948
+ $new_fields = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
949
 
950
+ if ( count( $options['buttons'] ) > 0 ) :
951
+ foreach ( $options['buttons'] as $btn ) :
952
+
953
+ if( get_post_meta( $order->id, ''.$btn['cow'].'', true ) ) {
954
+ $new_fields[''.$btn['cow'].''] = array(
955
+ 'label' => ''.wpml_string_wccm($btn['label']).'',
956
+ 'value' => get_post_meta( $order->id, ''.$btn['cow'].'', true )
957
+ );
958
+ }
959
+ endforeach;
960
+ endif;
961
 
962
+ return array_merge( $fields, $new_fields );
963
  }
 
964
 
965
+ // ================ Add field names to WPML String Translation ===============
966
  function wpml_string_wccm($input) {
967
+ if (function_exists( 'icl_t' )) {
968
+ return icl_t('WooCommerce Checkout Manager', ''.$input.'', ''.$input.'');
969
+ } else {
970
+ return $input;
971
+ }
 
 
972
  }