Consolidate value for checkbox input types
This commit is contained in:
parent
c7bd680579
commit
32566c508e
|
@ -688,16 +688,16 @@ class WC_Checkout {
|
||||||
$is_checkout_page = isset( $_REQUEST['woocommerce-process-checkout-nonce'] );
|
$is_checkout_page = isset( $_REQUEST['woocommerce-process-checkout-nonce'] );
|
||||||
|
|
||||||
foreach ( $fieldset as $key => $field ) {
|
foreach ( $fieldset as $key => $field ) {
|
||||||
if ( isset( $_POST[ $key ] ) ) { // phpcs:disable WordPress.Security.NonceVerification.Missing
|
$type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' );
|
||||||
|
|
||||||
|
if ( isset( $_POST[ $key ] ) && '' !== $_POST[ $key ] ) { // phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||||
$value = wp_unslash( $_POST[ $key ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
$value = wp_unslash( $_POST[ $key ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||||
} elseif ( isset( $field['default'] ) && ! $is_checkout_page ) {
|
} elseif ( isset( $field['default'] ) && 'checkbox' !== $type ) {
|
||||||
$value = '1' === (string) $field['default'] ? 1 : '';
|
$value = $field['default'];
|
||||||
} else {
|
} else {
|
||||||
$value = '';
|
$value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' );
|
|
||||||
|
|
||||||
if ( '' !== $value ) {
|
if ( '' !== $value ) {
|
||||||
switch ( $type ) {
|
switch ( $type ) {
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
|
|
Loading…
Reference in New Issue