Skip to content

Commit 01a9a43

Browse files
authored
release: fixes
- Fixed an issue where the max checked option was not enforcing the selection limit, allowing users to select more options than specified. - Fixed an issue where conditional logic based on checkbox selections was not functioning, preventing fields from being displayed correctly based on user choices.
2 parents 737da4b + 25bcb16 commit 01a9a43

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

inc/woocommerce.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,19 @@ function ppom_check_validation( $product_id, $post_data, $passed = true ) {
228228
continue;
229229
}
230230

231-
if ( ! isset( $field['required'] ) || 'on' !== $field['required'] ) {
232-
continue;
233-
}
234-
235-
$passed = apply_filters( 'ppom_before_fields_validation', $passed, $field, $post_data, $product_id );
236-
237231
if (
238-
empty( $field['data_name'] ) &&
239-
empty( $field['required'] ) &&
240-
empty( $field['min_checked'] ) &&
241-
empty( $field['max_checked'] )
232+
empty( $field['data_name'] ) ||
233+
(
234+
( ! isset( $field['required'] ) || 'on' !== $field['required'] ) &&
235+
empty( $field['min_checked'] ) &&
236+
empty( $field['max_checked'] )
237+
)
242238
) {
243239
continue;
244240
}
245241

242+
$passed = apply_filters( 'ppom_before_fields_validation', $passed, $field, $post_data, $product_id );
243+
246244
$data_name = sanitize_key( $field['data_name'] );
247245

248246
$title = isset( $field['title'] ) ? $field['title'] : '';

js/admin/ppom-admin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// @ts-check
22
"use strict";
33

4-
const FIELD_COMPATIBLE_WITH_SELECT_OPTIONS = [ 'select', 'radio', 'switcher', 'image','conditional_meta'];
4+
const FIELD_COMPATIBLE_WITH_SELECT_OPTIONS = [ 'select', 'radio', 'switcher', 'image', 'conditional_meta' ];
55
const OPERATOR_COMPARISON_VALUE_FIELD_TYPE = {
6-
'select': FIELD_COMPATIBLE_WITH_SELECT_OPTIONS,
6+
'select': [...FIELD_COMPATIBLE_WITH_SELECT_OPTIONS, 'checkbox'],
77
}
88
const COMPARISON_VALUE_CAN_USE_SELECT = [ 'is', 'not', 'greater than', 'less than' ];
99
const HIDE_COMPARISON_INPUT_FIELD = ['any', 'empty', 'odd-number', 'even-number'];
1010
const FIELDS_COMPATIBLE_WITH_TEXT = [ 'text', 'textarea', 'date', 'email' ]
1111
const FIELDS_COMPATIBLE_WITH_NUMBERS = [ ...FIELD_COMPATIBLE_WITH_SELECT_OPTIONS, 'number' ];
1212
const OPERATORS_FIELD_COMPATIBILITY = {
13-
'is': [...FIELD_COMPATIBLE_WITH_SELECT_OPTIONS, ...FIELDS_COMPATIBLE_WITH_TEXT, ...FIELDS_COMPATIBLE_WITH_NUMBERS, 'checkbox',],
13+
'is': [...FIELD_COMPATIBLE_WITH_SELECT_OPTIONS, ...FIELDS_COMPATIBLE_WITH_TEXT, ...FIELDS_COMPATIBLE_WITH_NUMBERS, 'checkbox'],
1414
'not': [...FIELD_COMPATIBLE_WITH_SELECT_OPTIONS, ...FIELDS_COMPATIBLE_WITH_TEXT, ...FIELDS_COMPATIBLE_WITH_NUMBERS, 'checkbox'],
1515
'greater than': FIELDS_COMPATIBLE_WITH_NUMBERS,
1616
'less than': FIELDS_COMPATIBLE_WITH_NUMBERS,

0 commit comments

Comments
 (0)