From 79db2d95a0a8beacbb73f6d116967e15e5ca372b Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Mon, 17 May 2021 17:15:16 -0500 Subject: [PATCH] Use default value only if form was displayed to the user Also changed variable name for readability --- includes/class-wc-checkout.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 045aba056a1..ef46e957905 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -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 = '';