From 506dac269eb150a9e88b865e599d172e555659ae Mon Sep 17 00:00:00 2001 From: Joey Kudish Date: Thu, 6 Jun 2024 01:55:34 -0700 Subject: [PATCH] Replace truthy check with isset when setting default checkout field value (#48031) Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com> --- plugins/woocommerce/changelog/pr-48031 | 4 ++++ .../woocommerce/src/Blocks/Domain/Services/CheckoutFields.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/pr-48031 diff --git a/plugins/woocommerce/changelog/pr-48031 b/plugins/woocommerce/changelog/pr-48031 new file mode 100644 index 00000000000..be4ca3a4b34 --- /dev/null +++ b/plugins/woocommerce/changelog/pr-48031 @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix a bug with the woocommerce_get_default_value_for_{key} filter that was preventing setting a falsey value on a checkbox (i.e. to uncheck it dynamically) diff --git a/plugins/woocommerce/src/Blocks/Domain/Services/CheckoutFields.php b/plugins/woocommerce/src/Blocks/Domain/Services/CheckoutFields.php index 274eeb4f2a5..709f9657337 100644 --- a/plugins/woocommerce/src/Blocks/Domain/Services/CheckoutFields.php +++ b/plugins/woocommerce/src/Blocks/Domain/Services/CheckoutFields.php @@ -1187,7 +1187,7 @@ class CheckoutFields { */ $value = apply_filters( "woocommerce_get_default_value_for_{$missing_field}", null, $group, $wc_object ); - if ( $value ) { + if ( isset( $value ) ) { $meta_data[ $missing_field ] = $value; } }