WooCommerce Checkout Manager - Version 6.0.7.4

Version Description

Download this release

Release Info

Developer quadlayers
Plugin Icon 128x128 WooCommerce Checkout Manager
Version 6.0.7.4
Comparing to
See all releases

Code changes from version 6.0.7.3 to 6.0.7.4

includes/class-wooccm.php CHANGED
@@ -36,7 +36,8 @@ final class WOOCCM
36
  $this->shipping = WOOCCM_Field_Shipping::instance();
37
  $this->additional = WOOCCM_Field_Additional::instance();
38
 
39
- include_once(WOOCCM_PLUGIN_DIR . 'includes/class-wooccm-compatibility.php');
 
40
  }
41
 
42
  public function includes()
36
  $this->shipping = WOOCCM_Field_Shipping::instance();
37
  $this->additional = WOOCCM_Field_Additional::instance();
38
 
39
+ //1326
40
+ // include_once(WOOCCM_PLUGIN_DIR . 'includes/class-wooccm-compatibility.php');
41
  }
42
 
43
  public function includes()
includes/model/class-wooccm-model.php CHANGED
@@ -1,152 +1,136 @@
1
  <?php
2
 
3
- class WOOCCM_Model
4
- {
5
 
6
- protected $table = '';
7
- private $cache = array();
8
 
 
 
9
 
10
- protected function get_args()
11
- {
12
- return array();
13
- }
14
 
15
- protected function get_next_id()
16
- {
 
17
 
18
- $items = $this->get_items();
 
19
 
20
- if (count($items)) {
21
- return max(array_keys($items)) + 1;
22
- }
23
 
24
- return 0;
25
- }
26
 
27
- // Singular
28
- protected function add_item($item_data)
29
- {
30
- $id = $this->get_next_id();
31
- $item_data['id'] = $id;
32
 
33
- $items = $this->get_items();
34
 
35
- $items[$id] = $item_data;
36
 
37
- return $this->save_items($items);
38
- }
39
 
40
- protected function get_item($id = null)
41
- {
42
 
43
- $items = $this->get_items();
 
 
 
44
 
45
- if (isset($items[$id])) {
46
- return $items[$id];
47
- }
48
- }
49
 
50
- protected function update_item($item_data = null)
51
- {
52
 
53
- if (!isset($item_data['id'])) {
54
- return false;
55
- }
56
 
57
- $items = $this->get_items();
58
 
59
- if (!isset($items[$item_data['id']])) {
60
- return false;
61
- }
62
 
63
- $items = $this->get_items();
 
64
 
65
- $items[$item_data['id']] = $item_data;
 
 
 
 
 
 
 
 
66
 
67
- return $this->save_items($items);
68
- }
 
69
 
70
- protected function delete_item($id = null)
71
- {
72
- $items = $this->get_items();
73
- if ($items) {
74
- if (count($items) > 0) {
75
- unset($items[$id]);
76
- return $this->save($items);
77
- }
78
- }
79
- }
80
 
81
- // Plural
82
- protected function get_items()
83
- {
84
 
85
- $items = $this->get();
86
 
87
- //make sure each item has all values
88
- if (is_array($items)) {
89
- if (count($items)) {
90
- foreach ($items as $id => $item) {
91
- $items[$id] = array_replace_recursive($this->get_args(), $item);
92
- }
93
- return $items;
94
- }
95
- }
96
 
97
- return array();
98
- }
99
 
100
- protected function save_items($items)
101
- {
 
102
 
103
- if (is_array($items)) {
 
104
 
105
- foreach ($items as $id => $item) {
 
 
106
 
107
- if (!isset($item['id'])) {
108
- unset($items[$id]);
109
- }
 
 
 
110
 
111
- $items[$id] = array_replace_recursive($this->get_args(), $item);
112
- }
113
 
114
- return $this->save($items);
115
- }
116
- }
117
 
118
- // Core
119
- protected function save($data = null)
120
- {
 
 
121
 
122
- if (!$this->table) {
123
- error_log('Model can\'t be accesed directly');
124
- die();
125
- }
126
 
127
- $this->cache[$this->table] = $data;
128
 
129
- return update_option($this->table, $data);
130
- }
131
 
132
- protected function get()
133
- {
134
-
135
- if (!$this->table) {
136
- error_log('Model can\'t be accesed directly');
137
- die();
138
- }
139
-
140
- if (!isset($this->cache[$this->table])) {
141
- $this->cache[$this->table] = get_option($this->table, $this->get_defaults());
142
- }
143
-
144
- return $this->cache[$this->table];
145
- }
146
-
147
- protected function delete()
148
- {
149
- delete_option($this->table);
150
- //update_option($this->table, $this->get_defaults());
151
- }
152
  }
1
  <?php
2
 
3
+ class WOOCCM_Model {
 
4
 
 
 
5
 
6
+ protected $table = '';
7
+ private $cache = array();
8
 
 
 
 
 
9
 
10
+ protected function get_args() {
11
+ return array();
12
+ }
13
 
14
+ protected function get_next_id() {
15
+ $items = $this->get_items();
16
 
17
+ if ( count( $items ) ) {
18
+ return max( array_keys( $items ) ) + 1;
19
+ }
20
 
21
+ return 0;
22
+ }
23
 
24
+ // Singular
25
+ protected function add_item( $item_data ) {
26
+ $id = $this->get_next_id();
27
+ $item_data['id'] = $id;
 
28
 
29
+ $items = $this->get_items();
30
 
31
+ $items[ $id ] = $item_data;
32
 
33
+ return $this->save_items( $items );
34
+ }
35
 
36
+ protected function get_item( $id = null ) {
37
+ $items = $this->get_items();
38
 
39
+ if ( isset( $items[ $id ] ) ) {
40
+ return $items[ $id ];
41
+ }
42
+ }
43
 
44
+ protected function update_item( $item_data = null ) {
45
+ if ( ! isset( $item_data['id'] ) ) {
46
+ return false;
47
+ }
48
 
49
+ $items = $this->get_items();
 
50
 
51
+ if ( ! isset( $items[ $item_data['id'] ] ) ) {
52
+ return false;
53
+ }
54
 
55
+ $items = $this->get_items();
56
 
57
+ $items[ $item_data['id'] ] = $item_data;
 
 
58
 
59
+ return $this->save_items( $items );
60
+ }
61
 
62
+ protected function delete_item( $id = null ) {
63
+ $items = $this->get_items();
64
+ if ( $items ) {
65
+ if ( count( $items ) > 0 ) {
66
+ unset( $items[ $id ] );
67
+ return $this->save( $items );
68
+ }
69
+ }
70
+ }
71
 
72
+ // Plural
73
+ protected function get_items() {
74
+ $items = $this->get();
75
 
76
+ // make sure each item has all values
77
+ if ( is_array( $items ) ) {
78
+ if ( count( $items ) ) {
79
+ foreach ( $items as $id => $item ) {
80
+ $items[ $id ] = array_replace_recursive( $this->get_args(), $item );
81
+ }
82
+ return $items;
83
+ }
84
+ }
 
85
 
86
+ return array();
87
+ }
 
88
 
89
+ protected function save_items( $items ) {
90
 
91
+ if ( is_array( $items ) ) {
 
 
 
 
 
 
 
 
92
 
93
+ foreach ( $items as $id => $item ) {
 
94
 
95
+ if ( ! isset( $item['id'] ) ) {
96
+ unset( $items[ $id ] );
97
+ }
98
 
99
+ $items[ $id ] = array_replace_recursive( $this->get_args(), $item );
100
+ }
101
 
102
+ return $this->save( $items );
103
+ }
104
+ }
105
 
106
+ // Core
107
+ protected function save( $data = null ) {
108
+ if ( ! $this->table ) {
109
+ error_log( 'Model can\'t be accesed directly' );
110
+ die();
111
+ }
112
 
113
+ $this->cache[ $this->table ] = $data;
 
114
 
115
+ return update_option( $this->table, $data );
116
+ }
 
117
 
118
+ protected function get() {
119
+ if ( ! $this->table ) {
120
+ error_log( 'Model can\'t be accesed directly' );
121
+ die();
122
+ }
123
 
124
+ if ( ! isset( $this->cache[ $this->table ] ) ) {
125
+ $this->cache[ $this->table ] = get_option( $this->table, $this->get_defaults() );
 
 
126
 
127
+ }
128
 
129
+ return $this->cache[ $this->table ];
130
+ }
131
 
132
+ protected function delete() {
133
+ delete_option( $this->table );
134
+ // update_option($this->table, $this->get_defaults());
135
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
includes/view/frontend/class-wooccm-fields-conditional.php CHANGED
@@ -32,7 +32,7 @@ class WOOCCM_Fields_Conditional
32
  // Unset if parent is disabled
33
  // -----------------------------------------------------------------
34
  if (empty($fields[$field['conditional_parent_key']])) {
35
- unset($fields[$field['key']]);
36
  continue;
37
  }
38
 
@@ -43,7 +43,7 @@ class WOOCCM_Fields_Conditional
43
  // Remove required attribute for hidden child fields
44
  $field['required'] = false;
45
  // Don't save hidden child fields in order
46
- unset($fields[$field['key']]);
47
  unset($_POST[$field['key']]);
48
  }
49
  // On update
@@ -55,7 +55,7 @@ class WOOCCM_Fields_Conditional
55
 
56
  if (!isset($post_data[$field['conditional_parent_key']]) || !isset($field['conditional_parent_value']) || !array_intersect((array) $field['conditional_parent_value'], (array) $post_data[$field['conditional_parent_key']])) {
57
  // Remove field fee
58
- unset($fields[$field['key']]);
59
  unset($_POST[$field['key']]);
60
  }
61
  }
32
  // Unset if parent is disabled
33
  // -----------------------------------------------------------------
34
  if (empty($fields[$field['conditional_parent_key']])) {
35
+ // unset($fields[$field['key']]);
36
  continue;
37
  }
38
 
43
  // Remove required attribute for hidden child fields
44
  $field['required'] = false;
45
  // Don't save hidden child fields in order
46
+ // unset($fields[$field['key']]);
47
  unset($_POST[$field['key']]);
48
  }
49
  // On update
55
 
56
  if (!isset($post_data[$field['conditional_parent_key']]) || !isset($field['conditional_parent_value']) || !array_intersect((array) $field['conditional_parent_value'], (array) $post_data[$field['conditional_parent_key']])) {
57
  // Remove field fee
58
+ // unset($fields[$field['key']]);
59
  unset($_POST[$field['key']]);
60
  }
61
  }
includes/view/frontend/class-wooccm-fields-register.php CHANGED
@@ -14,11 +14,14 @@ class WOOCCM_Fields_Register {
14
 
15
  // Billing fields
16
  // -----------------------------------------------------------------------
17
- add_filter( 'woocommerce_billing_fields', array( $this, 'add_billing_fields' ), 999 );
 
18
 
19
  // Shipping fields
20
  // -----------------------------------------------------------------------
21
- add_filter( 'woocommerce_shipping_fields', array( $this, 'add_shipping_fields' ), 999 );
 
 
22
 
23
  // Additional fields
24
  // -----------------------------------------------------------------------
@@ -37,17 +40,70 @@ class WOOCCM_Fields_Register {
37
  return self::$_instance;
38
  }
39
 
40
- public function add_billing_fields( $fields ) {
 
 
 
 
 
 
 
 
41
  $wooccm_fields = WOOCCM()->billing->get_fields();
42
- return array_merge( $fields, $wooccm_fields );
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
- public function add_shipping_fields( $fields ) {
 
 
 
 
 
 
 
 
46
  $wooccm_fields = WOOCCM()->shipping->get_fields();
47
- return array_merge( $fields, $wooccm_fields );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  public function add_my_account_fields( $defaults, $load_address ) {
 
51
  if ( isset( WOOCCM()->$load_address ) ) {
52
 
53
  $fields = WOOCCM()->$load_address->get_fields();
@@ -65,17 +121,17 @@ class WOOCCM_Fields_Register {
65
  }
66
  }
67
 
68
- return $fields;
 
 
 
 
 
69
  }
70
 
71
  return $defaults;
72
  }
73
 
74
- public function add_additional_fields( $fields ) {
75
- $fields['additional'] = WOOCCM()->additional->get_fields();
76
- return $fields;
77
- }
78
-
79
  // public function add_keys( $fields ) {
80
  // $frontend_fields = array();
81
 
14
 
15
  // Billing fields
16
  // -----------------------------------------------------------------------
17
+ // add_filter( 'woocommerce_billing_fields', array( $this, 'add_billing_fields' ), 999 );
18
+ add_filter( 'woocommerce_checkout_fields', array( $this, 'add_billing_fields_beta' ), 999 );
19
 
20
  // Shipping fields
21
  // -----------------------------------------------------------------------
22
+ // There is an issue when the Settings -> Shipping -> Hide shipping costs. Until an address is entered is activated
23
+ // add_filter( 'woocommerce_shipping_fields', array( $this, 'add_shipping_fields' ), 999 );
24
+ add_filter( 'woocommerce_checkout_fields', array( $this, 'add_shipping_fields_beta' ), 999 );
25
 
26
  // Additional fields
27
  // -----------------------------------------------------------------------
40
  return self::$_instance;
41
  }
42
 
43
+ // public function add_billing_fields( $fields ) {
44
+ // $wooccm_fields = WOOCCM()->billing->get_fields();
45
+ // return array_merge( $fields, $wooccm_fields );
46
+ // }
47
+
48
+ public function add_billing_fields_beta( $fields ) {
49
+ if ( ! isset( $fields['shipping'] ) ) {
50
+ return $fields;
51
+ }
52
  $wooccm_fields = WOOCCM()->billing->get_fields();
53
+ if ( empty( $wooccm_fields ) ) {
54
+ return $fields;
55
+ }
56
+ $fields['billing'] = array_merge( $fields['billing'], $wooccm_fields );
57
+
58
+ $fields['billing'] = array_filter(
59
+ $fields['billing'],
60
+ function ( $field ) {
61
+ return ( empty( $field['disabled'] ) );
62
+ }
63
+ );
64
+
65
+ return $fields;
66
  }
67
 
68
+ // public function add_shipping_fields( $fields ) {
69
+ // $wooccm_fields = WOOCCM()->shipping->get_fields();
70
+ // return array_merge( $fields, $wooccm_fields );
71
+ // }
72
+
73
+ public function add_shipping_fields_beta( $fields ) {
74
+ if ( ! isset( $fields['shipping'] ) ) {
75
+ return $fields;
76
+ }
77
  $wooccm_fields = WOOCCM()->shipping->get_fields();
78
+ if ( empty( $wooccm_fields ) ) {
79
+ return $fields;
80
+ }
81
+ $fields['shipping'] = array_merge( $fields['shipping'], $wooccm_fields );
82
+
83
+ $fields['shipping'] = array_filter(
84
+ $fields['shipping'],
85
+ function ( $field ) {
86
+ return ( empty( $field['disabled'] ) );
87
+ }
88
+ );
89
+
90
+ return $fields;
91
+ }
92
+
93
+ public function add_additional_fields( $fields ) {
94
+ $fields['additional'] = WOOCCM()->additional->get_fields();
95
+ $fields['additional'] = array_filter(
96
+ $fields['additional'],
97
+ function ( $field ) {
98
+ return ( empty( $field['disabled'] ) );
99
+ }
100
+ );
101
+
102
+ return $fields;
103
  }
104
 
105
  public function add_my_account_fields( $defaults, $load_address ) {
106
+
107
  if ( isset( WOOCCM()->$load_address ) ) {
108
 
109
  $fields = WOOCCM()->$load_address->get_fields();
121
  }
122
  }
123
 
124
+ return array_filter(
125
+ $fields,
126
+ function ( $field ) {
127
+ return ( empty( $field['disabled'] ) );
128
+ }
129
+ );
130
  }
131
 
132
  return $defaults;
133
  }
134
 
 
 
 
 
 
135
  // public function add_keys( $fields ) {
136
  // $frontend_fields = array();
137
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: checkout field editor, woocommerce checkout field editor, checkout manager
5
  Requires at least: 4.9
6
  Tested up to: 6.0.1
7
  Requires PHP: 5.6
8
- Stable tag: 6.0.7.3
9
  WC requires at least: 3.1.0
10
  WC tested up to: 6.6.1
11
  License: GPLv3
@@ -149,8 +149,9 @@ Your Order data can be reviewed in each order within the default WooCommerce Ord
149
 
150
  == Changelog ==
151
 
152
- = 6.0.7.3
153
  * Fix. WooCommerce Checkout remove fields
 
154
 
155
  = 6.0.7.2
156
  * Fix. WooCommerce Checkout email settings save
5
  Requires at least: 4.9
6
  Tested up to: 6.0.1
7
  Requires PHP: 5.6
8
+ Stable tag: 6.0.7.4
9
  WC requires at least: 3.1.0
10
  WC tested up to: 6.6.1
11
  License: GPLv3
149
 
150
  == Changelog ==
151
 
152
+ = 6.0.7.4
153
  * Fix. WooCommerce Checkout remove fields
154
+ * Fix. WooCommerce Checkout conditional fields
155
 
156
  = 6.0.7.2
157
  * Fix. WooCommerce Checkout email settings save
woocommerce-checkout-manager.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Checkout Fields Manager for WooCommerce
5
  * Plugin URI: https://quadlayers.com/portfolio/woocommerce-checkout-manager/
6
  * Description: Manage and customize WooCommerce Checkout fields (Add, Edit, Delete or re-order fields).
7
- * Version: 6.0.7.3
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * License: GPLv3
@@ -20,7 +20,7 @@ if ( ! defined( 'WOOCCM_PLUGIN_NAME' ) ) {
20
  define( 'WOOCCM_PLUGIN_NAME', 'Checkout Fields Manager for WooCommerce' );
21
  }
22
  if ( ! defined( 'WOOCCM_PLUGIN_VERSION' ) ) {
23
- define( 'WOOCCM_PLUGIN_VERSION', '6.0.7.3' );
24
  }
25
  if ( ! defined( 'WOOCCM_PLUGIN_FILE' ) ) {
26
  define( 'WOOCCM_PLUGIN_FILE', __FILE__ );
4
  * Plugin Name: Checkout Fields Manager for WooCommerce
5
  * Plugin URI: https://quadlayers.com/portfolio/woocommerce-checkout-manager/
6
  * Description: Manage and customize WooCommerce Checkout fields (Add, Edit, Delete or re-order fields).
7
+ * Version: 6.0.7.4
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * License: GPLv3
20
  define( 'WOOCCM_PLUGIN_NAME', 'Checkout Fields Manager for WooCommerce' );
21
  }
22
  if ( ! defined( 'WOOCCM_PLUGIN_VERSION' ) ) {
23
+ define( 'WOOCCM_PLUGIN_VERSION', '6.0.7.4' );
24
  }
25
  if ( ! defined( 'WOOCCM_PLUGIN_FILE' ) ) {
26
  define( 'WOOCCM_PLUGIN_FILE', __FILE__ );