Consolidate value for checkbox input types

This commit is contained in:
Alfredo Sumaran 2021-05-12 13:34:18 -05:00
parent c7bd680579
commit 32566c508e
1 changed files with 5 additions and 5 deletions

View File

@ -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':