Flexible Checkout Fields for WooCommerce – WooCommerce Checkout Manager - Version 1.2.2

Version Description

  • 2016-09-16 =
  • Fixed removing the last field from the section
  • Fixed checkboxes default settings
  • Fixed select not showing up
  • Fixed removing order notes field
Download this release

Release Info

Developer wpdesk
Plugin Icon wp plugin Flexible Checkout Fields for WooCommerce – WooCommerce Checkout Manager
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

class/inspireCheckoutFieldsSettings.php CHANGED
@@ -37,7 +37,7 @@
37
  $billing = $countries->get_address_fields($countries->get_base_country(), 'billing_');
38
  $shipping = $countries->get_address_fields($countries->get_base_country(), 'shipping_');
39
 
40
- if( empty( $settings ) || empty( $settings['order'] ) ) {
41
  $order = array(
42
  'order_comments' => array(
43
  'type' => 'textarea',
@@ -45,7 +45,7 @@
45
  'label' => __( 'Order Notes', 'flexible-checkout-fields' ),
46
  'placeholder' => _x( 'Notes about your order, e.g. special notes for delivery.', 'placeholder', 'flexible-checkout-fields')
47
  )
48
- );
49
  }
50
  else {
51
  $order = $settings['order'];
@@ -121,9 +121,9 @@
121
 
122
  public function updateSettingsAction(){
123
  if ( !empty( $_POST ) ) {
124
- if ( !empty($_POST['option_page']) && in_array($_POST['option_page'], array('inspire_checkout_fields_settings', 'inspire_checkout_fields_checkboxes') ) ) {
125
  if ( !empty( $_POST[$this->getNamespace()] ) ) {
126
- foreach ( $_POST[$this->getNamespace()] as $name => $value ) {
127
  $settings = get_option( 'inspire_checkout_fields_' . $name, array() );
128
  if ( is_array( $value )) {
129
  foreach ( $value as $key => $val ) {
37
  $billing = $countries->get_address_fields($countries->get_base_country(), 'billing_');
38
  $shipping = $countries->get_address_fields($countries->get_base_country(), 'shipping_');
39
 
40
+ if( empty( $settings ) || empty( $settings['order'] ) ) {
41
  $order = array(
42
  'order_comments' => array(
43
  'type' => 'textarea',
45
  'label' => __( 'Order Notes', 'flexible-checkout-fields' ),
46
  'placeholder' => _x( 'Notes about your order, e.g. special notes for delivery.', 'placeholder', 'flexible-checkout-fields')
47
  )
48
+ );
49
  }
50
  else {
51
  $order = $settings['order'];
121
 
122
  public function updateSettingsAction(){
123
  if ( !empty( $_POST ) ) {
124
+ if ( !empty($_POST['option_page']) && in_array( $_POST['option_page'], array('inspire_checkout_fields_settings', 'inspire_checkout_fields_checkboxes') ) ) {
125
  if ( !empty( $_POST[$this->getNamespace()] ) ) {
126
+ foreach ( $_POST[$this->getNamespace()] as $name => $value ) {
127
  $settings = get_option( 'inspire_checkout_fields_' . $name, array() );
128
  if ( is_array( $value )) {
129
  foreach ( $value as $key => $val ) {
class/views/settings-fields.php CHANGED
@@ -98,6 +98,7 @@
98
 
99
  <?php foreach ( $checkout_fields as $key => $fields ): ?>
100
  <?php if ( 'fields_' . $key != $current_tab ) continue; ?>
 
101
  <div id="post-body" class="fields-container">
102
  <h3><?php _e( 'Section Fields', 'flexible-checkout-fields' ) ?> <?php //echo $checkout_field_type_name[$key] ?></h3>
103
 
@@ -153,16 +154,27 @@
153
  </label>
154
  </div>
155
 
156
- <div>
 
 
 
 
 
 
 
 
 
 
157
  <input type="hidden" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][required]" value="0" />
158
-
159
  <label>
160
- <input type="checkbox" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][required]" value="1" <?php if( $field_required ): ?> checked<?php endif; ?>>
161
  <?php _e( 'Required Field', 'flexible-checkout-fields' ) ?>
162
  </label>
163
  </div>
164
 
165
- <div class="field-type-label">
 
166
  <label for="label_<?php echo $name ?>"><?php _e( 'Label', 'flexible-checkout-fields' ) ?></label>
167
 
168
  <textarea id="label_<?php echo $name ?>" class="field-name" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][label]"><?php if(isset($settings[$key][$name]['label'])): echo stripslashes($settings[$key][$name]['label']); elseif(isset($field['label'])): echo $field['label']; endif; ?></textarea>
@@ -171,10 +183,16 @@
171
  </div>
172
 
173
  <?php if( $is_custom_field ): ?>
 
 
 
 
 
 
174
  <div class="element-option<?php if( isset($checkout_field_type[$settings[$key][$name]['type']]['has_options']) && $checkout_field_type[$settings[$key][$name]['type']]['has_options']) echo " show" ?>">
175
  <label for="option_<?php echo $name ?>"><?php _e( 'Options', 'flexible-checkout-fields' ) ?></label>
176
 
177
- <textarea id="option_<?php echo $name ?>" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][option]"><?php echo isset( $settings[$key][$name]['option'] )?$settings[$key][$name]['option']:''; ?></textarea>
178
 
179
  <p><?php _e( 'Format: <code>Value : Name</code>. Value will be in the code, name will be visible to the user. One option per line. Example:<br /><code>woman : I am a woman</code><br /><code>man : I am a man</code>', 'flexible-checkout-fields' ) ?></p>
180
  </div>
@@ -182,9 +200,15 @@
182
 
183
  <?php if( !$is_custom_field || empty( $checkout_field_type[$settings[$key][$name]['type']]['disable_placeholder'] ) || !$checkout_field_type[$settings[$key][$name]['type']]['disable_placeholder'] ): ?>
184
  <div class="field_placeholder">
 
 
 
 
 
 
185
  <label for="placeholder_<?php echo $name ?>"><?php if( $is_custom_field && isset( $checkout_field_type[$settings[$key][$name]['type']]['placeholder_label'] ) ): ?><?php echo $checkout_field_type[$settings[$key][$name]['type']]['placeholder_label']; ?><?php else: ?><?php _e( 'Placeholder', 'flexible-checkout-fields' ) ?><?php endif; ?></label>
186
 
187
- <input type="text" id="placeholder_<?php echo $name ?>" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][placeholder]" value="<?php if(!empty($settings[$key][$name]['placeholder'])): echo $settings[$key][$name]['placeholder']; else: echo isset($field['placeholder'])?$field['placeholder']:''; endif; ?>" />
188
  </div>
189
  <?php endif; ?>
190
 
@@ -369,11 +393,16 @@ jQuery(document).ready(function () {
369
  // When Saving Form Remove disabled from Selects
370
  jQuery('form').bind('submit', function () {
371
  jQuery(this).find('select').prop('disabled', false);
 
372
  });
373
 
374
  // Activate Spinner on Save
375
  jQuery('input[type="submit"]').on('click', function() {
376
- jQuery(this).closest('.major-publishing-actions').find('.spinner').css('visibility', 'visible');
 
 
 
 
377
  });
378
  });
379
 
98
 
99
  <?php foreach ( $checkout_fields as $key => $fields ): ?>
100
  <?php if ( 'fields_' . $key != $current_tab ) continue; ?>
101
+ <input type="hidden" name="inspire_checkout_fields[settings][<?php echo $key ?>]" value="" />
102
  <div id="post-body" class="fields-container">
103
  <h3><?php _e( 'Section Fields', 'flexible-checkout-fields' ) ?> <?php //echo $checkout_field_type_name[$key] ?></h3>
104
 
154
  </label>
155
  </div>
156
 
157
+ <?php
158
+ $checked = '';
159
+ $style = '';
160
+ if ( isset($checkout_field_type[$settings[$key][$name]['type']]['has_required']) && $checkout_field_type[$settings[$key][$name]['type']]['has_rquired'] == false ) {
161
+ $style = ' display:none; ';
162
+ }
163
+ else {
164
+ if( $field_required ) $checked = ' checked';
165
+ }
166
+ ?>
167
+ <div style="<?php echo $style; ?>">
168
  <input type="hidden" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][required]" value="0" />
169
+
170
  <label>
171
+ <input type="checkbox" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][required]" value="1" <?php echo $checked; ?>>
172
  <?php _e( 'Required Field', 'flexible-checkout-fields' ) ?>
173
  </label>
174
  </div>
175
 
176
+ <div class="field-type-label">
177
+
178
  <label for="label_<?php echo $name ?>"><?php _e( 'Label', 'flexible-checkout-fields' ) ?></label>
179
 
180
  <textarea id="label_<?php echo $name ?>" class="field-name" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][label]"><?php if(isset($settings[$key][$name]['label'])): echo stripslashes($settings[$key][$name]['label']); elseif(isset($field['label'])): echo $field['label']; endif; ?></textarea>
183
  </div>
184
 
185
  <?php if( $is_custom_field ): ?>
186
+ <?php
187
+ $required = '';
188
+ if( isset($checkout_field_type[$settings[$key][$name]['type']]['has_options']) && $checkout_field_type[$settings[$key][$name]['type']]['has_options']) {
189
+ $required = ' required';
190
+ }
191
+ ?>
192
  <div class="element-option<?php if( isset($checkout_field_type[$settings[$key][$name]['type']]['has_options']) && $checkout_field_type[$settings[$key][$name]['type']]['has_options']) echo " show" ?>">
193
  <label for="option_<?php echo $name ?>"><?php _e( 'Options', 'flexible-checkout-fields' ) ?></label>
194
 
195
+ <textarea id="option_<?php echo $name ?>" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][option]" <?php echo $required; ?>><?php echo isset( $settings[$key][$name]['option'] )?$settings[$key][$name]['option']:''; ?></textarea>
196
 
197
  <p><?php _e( 'Format: <code>Value : Name</code>. Value will be in the code, name will be visible to the user. One option per line. Example:<br /><code>woman : I am a woman</code><br /><code>man : I am a man</code>', 'flexible-checkout-fields' ) ?></p>
198
  </div>
200
 
201
  <?php if( !$is_custom_field || empty( $checkout_field_type[$settings[$key][$name]['type']]['disable_placeholder'] ) || !$checkout_field_type[$settings[$key][$name]['type']]['disable_placeholder'] ): ?>
202
  <div class="field_placeholder">
203
+ <?php
204
+ $required = '';
205
+ if( isset( $checkout_field_type[$settings[$key][$name]['type']]['label_is_required'] ) ) {
206
+ $required = ' required';
207
+ }
208
+ ?>
209
  <label for="placeholder_<?php echo $name ?>"><?php if( $is_custom_field && isset( $checkout_field_type[$settings[$key][$name]['type']]['placeholder_label'] ) ): ?><?php echo $checkout_field_type[$settings[$key][$name]['type']]['placeholder_label']; ?><?php else: ?><?php _e( 'Placeholder', 'flexible-checkout-fields' ) ?><?php endif; ?></label>
210
 
211
+ <input type="text" id="placeholder_<?php echo $name ?>" name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][placeholder]" value="<?php if(!empty($settings[$key][$name]['placeholder'])): echo $settings[$key][$name]['placeholder']; else: echo isset($field['placeholder'])?$field['placeholder']:''; endif; ?>" <?php echo $required; ?> />
212
  </div>
213
  <?php endif; ?>
214
 
393
  // When Saving Form Remove disabled from Selects
394
  jQuery('form').bind('submit', function () {
395
  jQuery(this).find('select').prop('disabled', false);
396
+ jQuery(this).find('.major-publishing-actions').find('.spinner').css('visibility', 'visible');
397
  });
398
 
399
  // Activate Spinner on Save
400
  jQuery('input[type="submit"]').on('click', function() {
401
+ jQuery('#inspire_checkout_field [required]').each(function(){
402
+ if ( jQuery(this).val() == '' && jQuery(this).is(':hidden') ) {
403
+ jQuery(this).closest('li').find('.item-controls>a').click();
404
+ }
405
+ });
406
  });
407
  });
408
 
flexible-checkout-fields.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Flexible Checkout Fields
4
  Plugin URI: https://www.wpdesk.net/products/flexible-checkout-fields-pro-woocommerce/
5
  Description: Manage your WooCommerce checkout fields. Change order, labels, placeholders and add new fields.
6
- Version: 1.2.1
7
  Author: WP Desk
8
  Author URI: https://www.wpdesk.net/
9
  Text Domain: flexible-checkout-fields
@@ -67,7 +67,7 @@
67
  add_action( 'wp_enqueue_scripts', array($this, 'initPublicCssAction'), 75 );
68
  add_action( 'wp_enqueue_scripts', array($this, 'initPublicJsAction'), 75 );
69
 
70
- add_action( 'woocommerce_checkout_fields', array( $this, 'changeCheckoutFields' ) );
71
  add_action( 'woocommerce_checkout_update_order_meta', array($this, 'updateCheckoutFields'));
72
 
73
  add_action( 'woocommerce_admin_billing_fields', array($this, 'changeAdminBillingFields'));
@@ -265,7 +265,10 @@
265
 
266
  public function getCheckoutFields( $fields, $request_type = null ) {
267
  $settings = $this->get_settings();
268
- if ( !empty( $settings ) ) {
 
 
 
269
  foreach ( $settings as $key => $type ) {
270
  if ( $key != 'billing' && $key != 'shipping' && $key != 'order' ) {
271
  if ( get_option('inspire_checkout_fields_' . $key, '0' ) == '0' ) {
@@ -273,9 +276,13 @@
273
  }
274
  }
275
  if ( $request_type == null || $request_type == $key ) {
 
 
 
276
  $fields_found = true;
277
  foreach ( $type as $field_name => $field ) {
278
- if( $field['visible'] == 0 or ($_GET['page'] == 'inspire_checkout_fields_settings' and $field['visible'] == 1) or $field['name'] == 'billing_country' or $field['name'] == 'shipping_country'){
 
279
  if ( isset( $fields[$key][$field['name']] ) ) {
280
  $new[$key][$field['name']] = $fields[$key][$field['name']];
281
  }
@@ -308,7 +315,7 @@
308
  if( isset( $field['custom_field'] ) && $field['custom_field'] == 1 ){
309
  $new[$key][$field['name']]['type'] = $field['type'];
310
 
311
- if( isset($field['has_options'] ) ){
312
  $array_options = explode("\n", $field['option']);
313
  if(!empty($array_options)){
314
  foreach ($array_options as $option) {
@@ -328,10 +335,9 @@
328
  }
329
  }
330
  }
331
-
332
  foreach ( $fields as $key => $value ) {
333
  if ( $request_type == null || $request_type == $key ) {
334
- if ( empty( $new[$key] ) ) {
335
  $new[$key] = $value;
336
  }
337
  }
@@ -343,7 +349,7 @@
343
  return $new;
344
  }
345
  else{
346
- return $new[$request_type];
347
  }
348
 
349
  }
@@ -355,6 +361,8 @@
355
  public function getCheckoutUserFields($fields, $request_type = null) {
356
  $settings = $this->get_settings();
357
 
 
 
358
  if ( !empty($settings[$request_type] ) ){
359
  foreach ( $settings[$request_type] as $key => $field ) {
360
  if($field['visible'] == 0 or $field['name'] == 'billing_country' or $field['name'] == 'shipping_country' or ($_GET['page'] == 'inspire_checkout_fields_settings' and $field['visible'] == 1)){
@@ -397,7 +405,7 @@
397
  $new[$key]['type'] = $field['type'];
398
  }
399
 
400
- if( isset( $field['type'] ) && ( !empty( $field['has_options'] ) ) ) {
401
  $array_options = explode("\n", $field['option']);
402
  if(!empty($array_options)){
403
  foreach ($array_options as $option) {
@@ -514,13 +522,15 @@
514
  public function addCustomFieldsToReview($order_id) {
515
  $settings = $this->get_settings();
516
 
 
 
517
  if(!empty($settings)){
518
  $return = array();
519
  foreach ($settings as $key => $type) {
520
  foreach ($type as $field) {
521
  if($field['visible'] == 0 && isset($field['custom_field']) && $field['custom_field'] == 1){
522
  if($value = get_post_meta( $order_id, '_'.$field['name'] , true )){
523
- if ( !empty( $field['has_options'] ) ) {
524
  $array_options = explode("\n", $field['option']);
525
  if(!empty($array_options)){
526
  foreach ($array_options as $option) {
3
  Plugin Name: Flexible Checkout Fields
4
  Plugin URI: https://www.wpdesk.net/products/flexible-checkout-fields-pro-woocommerce/
5
  Description: Manage your WooCommerce checkout fields. Change order, labels, placeholders and add new fields.
6
+ Version: 1.2.2
7
  Author: WP Desk
8
  Author URI: https://www.wpdesk.net/
9
  Text Domain: flexible-checkout-fields
67
  add_action( 'wp_enqueue_scripts', array($this, 'initPublicCssAction'), 75 );
68
  add_action( 'wp_enqueue_scripts', array($this, 'initPublicJsAction'), 75 );
69
 
70
+ add_action( 'woocommerce_checkout_fields', array( $this, 'changeCheckoutFields' ), 9999 );
71
  add_action( 'woocommerce_checkout_update_order_meta', array($this, 'updateCheckoutFields'));
72
 
73
  add_action( 'woocommerce_admin_billing_fields', array($this, 'changeAdminBillingFields'));
265
 
266
  public function getCheckoutFields( $fields, $request_type = null ) {
267
  $settings = $this->get_settings();
268
+ $checkout_field_type = $this->get_fields();
269
+ error_log('request_type='.$request_type);
270
+ if ( !empty( $settings ) ) {
271
+ $new = array();
272
  foreach ( $settings as $key => $type ) {
273
  if ( $key != 'billing' && $key != 'shipping' && $key != 'order' ) {
274
  if ( get_option('inspire_checkout_fields_' . $key, '0' ) == '0' ) {
276
  }
277
  }
278
  if ( $request_type == null || $request_type == $key ) {
279
+ if ( !isset( $new[$key] ) ) {
280
+ $new[$key] = array();
281
+ }
282
  $fields_found = true;
283
  foreach ( $type as $field_name => $field ) {
284
+ //error_log( print_r($field,true) );
285
+ if( $field['visible'] == 0 || ($_GET['page'] == 'inspire_checkout_fields_settings' && $field['visible'] == 1) || $field['name'] == 'billing_country' or $field['name'] == 'shipping_country' ){
286
  if ( isset( $fields[$key][$field['name']] ) ) {
287
  $new[$key][$field['name']] = $fields[$key][$field['name']];
288
  }
315
  if( isset( $field['custom_field'] ) && $field['custom_field'] == 1 ){
316
  $new[$key][$field['name']]['type'] = $field['type'];
317
 
318
+ if( isset($checkout_field_type[$field['type']]['has_options'] ) ){
319
  $array_options = explode("\n", $field['option']);
320
  if(!empty($array_options)){
321
  foreach ($array_options as $option) {
335
  }
336
  }
337
  }
 
338
  foreach ( $fields as $key => $value ) {
339
  if ( $request_type == null || $request_type == $key ) {
340
+ if ( empty( $settings[$key] ) ) {
341
  $new[$key] = $value;
342
  }
343
  }
349
  return $new;
350
  }
351
  else{
352
+ return $new[$request_type];
353
  }
354
 
355
  }
361
  public function getCheckoutUserFields($fields, $request_type = null) {
362
  $settings = $this->get_settings();
363
 
364
+ $checkout_field_type = $this->get_fields();
365
+
366
  if ( !empty($settings[$request_type] ) ){
367
  foreach ( $settings[$request_type] as $key => $field ) {
368
  if($field['visible'] == 0 or $field['name'] == 'billing_country' or $field['name'] == 'shipping_country' or ($_GET['page'] == 'inspire_checkout_fields_settings' and $field['visible'] == 1)){
405
  $new[$key]['type'] = $field['type'];
406
  }
407
 
408
+ if( isset( $field['type'] ) && ( !empty( $checkout_field_type[$field['type']]['has_options'] ) ) ) {
409
  $array_options = explode("\n", $field['option']);
410
  if(!empty($array_options)){
411
  foreach ($array_options as $option) {
522
  public function addCustomFieldsToReview($order_id) {
523
  $settings = $this->get_settings();
524
 
525
+ $checkout_field_type = $this->get_fields();
526
+
527
  if(!empty($settings)){
528
  $return = array();
529
  foreach ($settings as $key => $type) {
530
  foreach ($type as $field) {
531
  if($field['visible'] == 0 && isset($field['custom_field']) && $field['custom_field'] == 1){
532
  if($value = get_post_meta( $order_id, '_'.$field['name'] , true )){
533
+ if ( !empty( $checkout_field_type[$field['type']]['has_options'] ) ) {
534
  $array_options = explode("\n", $field['option']);
535
  if(!empty($array_options)){
536
  foreach ($array_options as $option) {
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wpdesk, swoboda, jablonowski
3
  Donate link: https://www.wpdesk.net/flexible-checkout-fields-woocommerce/
4
  Tags: woocommerce checkout, woocommerce checkout fields, flexible checkout fields, woocommerce checkout manager, woocommerce checkout editor, woocommerce fields manager, woocommerce fields editor, woocommerce custom checkout fields, woocommerce checkout options, woocommerce checkout pro, woocommerce custom sections, woocommerce file upload
5
  Requires at least: 4.0
6
- Tested up to: 4.6
7
- Stable tag: 1.2.1
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -129,6 +129,12 @@ If you are upgrading from the old WooCommerce Checkout Fields version (1.1, wooc
129
 
130
  == Changelog ==
131
 
 
 
 
 
 
 
132
  = 1.2.1 - 2016-09-08 =
133
  * Fixed saving select field
134
 
3
  Donate link: https://www.wpdesk.net/flexible-checkout-fields-woocommerce/
4
  Tags: woocommerce checkout, woocommerce checkout fields, flexible checkout fields, woocommerce checkout manager, woocommerce checkout editor, woocommerce fields manager, woocommerce fields editor, woocommerce custom checkout fields, woocommerce checkout options, woocommerce checkout pro, woocommerce custom sections, woocommerce file upload
5
  Requires at least: 4.0
6
+ Tested up to: 4.6.1
7
+ Stable tag: 1.2.2
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
129
 
130
  == Changelog ==
131
 
132
+ = 1.2.2 - 2016-09-16 =
133
+ * Fixed removing the last field from the section
134
+ * Fixed checkboxes default settings
135
+ * Fixed select not showing up
136
+ * Fixed removing order notes field
137
+
138
  = 1.2.1 - 2016-09-08 =
139
  * Fixed saving select field
140