Use default value only if form was displayed to the user
Also changed variable name for readability
This commit is contained in:
parent
32566c508e
commit
79db2d95a0
|
@ -685,14 +685,14 @@ class WC_Checkout {
|
|||
continue;
|
||||
}
|
||||
|
||||
$is_checkout_page = isset( $_REQUEST['woocommerce-process-checkout-nonce'] );
|
||||
$form_was_shown = isset( $_REQUEST['woocommerce-process-checkout-nonce'] );
|
||||
|
||||
foreach ( $fieldset as $key => $field ) {
|
||||
$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
|
||||
} elseif ( isset( $field['default'] ) && 'checkbox' !== $type ) {
|
||||
} elseif ( isset( $field['default'] ) && 'checkbox' !== $type && ! $form_was_shown ) {
|
||||
$value = $field['default'];
|
||||
} else {
|
||||
$value = '';
|
||||
|
|
Loading…
Reference in New Issue