Commit d57937f1e5f for woocommerce

commit d57937f1e5f2d44769a803f689a8a0667f7c45c2
Author: Anuj Singh <80690679+Anuj-Rathore24@users.noreply.github.com>
Date:   Thu Jun 18 16:32:38 2026 +0530

    Fix: Allow empty string values to be persisted in customer session (#65633)

    * Fix: allow empty string values to be persisted in customer session

    * chore: Add changelog

    ---------

    Co-authored-by: Raluca Stan <ralucastn@gmail.com>

diff --git a/plugins/woocommerce/changelog/fix-customer-session-empty-field-persistence b/plugins/woocommerce/changelog/fix-customer-session-empty-field-persistence
new file mode 100644
index 00000000000..ce0800070c6
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-customer-session-empty-field-persistence
@@ -0,0 +1,4 @@
+Significance: minor
+Type: fix
+
+Fix: allow empty customer session fields to override prior values in WC_Customer_Data_Store_Session
diff --git a/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store-session.php b/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store-session.php
index 631c76bceee..1821aaa2aef 100644
--- a/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store-session.php
+++ b/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store-session.php
@@ -121,7 +121,7 @@ class WC_Customer_Data_Store_Session extends WC_Data_Store_WP implements WC_Cust
 				if ( 'billing_' === substr( $session_key, 0, 8 ) ) {
 					$session_key = str_replace( 'billing_', '', $session_key );
 				}
-				if ( ! empty( $data[ $session_key ] ) && is_callable( array( $customer, "set_{$function_key}" ) ) ) {
+				if ( isset( $data[ $session_key ] ) && is_callable( array( $customer, "set_{$function_key}" ) ) ) {
 					if ( 'meta_data' === $session_key ) {
 						if ( is_array( $data[ $session_key ] ) ) {
 							foreach ( $data[ $session_key ] as $meta_data_value ) {
diff --git a/plugins/woocommerce/tests/php/includes/data-stores/class-wc-customer-data-store-session-test.php b/plugins/woocommerce/tests/php/includes/data-stores/class-wc-customer-data-store-session-test.php
index 9bf647a9602..31f94e7f0cd 100644
--- a/plugins/woocommerce/tests/php/includes/data-stores/class-wc-customer-data-store-session-test.php
+++ b/plugins/woocommerce/tests/php/includes/data-stores/class-wc-customer-data-store-session-test.php
@@ -172,4 +172,31 @@ class WC_Customer_Data_Store_Session_Test extends WC_Unit_Test_Case {
 		$customer->set_billing_state( $location['state'] );
 		return $customer;
 	}
+
+	/**
+	 * Ensure that empty string values can be persisted in customer session.
+	 */
+	public function test_empty_field_can_be_persisted_in_session() {
+		WC()->session->init();
+
+		$customer = new WC_Customer();
+		$customer->set_email( 'test@example.com' );
+		$customer->set_shipping_address_2( 'Apt 1' );
+		$customer->save();
+
+		// Session says address_2 is now empty (user cleared it).
+		WC()->session->set(
+			'customer',
+			array(
+				'id'                 => (string) $customer->get_id(),
+				'date_modified'      => (string) $customer->get_date_modified( 'edit' ),
+				'shipping_address_2' => '',
+			)
+		);
+
+		$data_store = new WC_Customer_Data_Store_Session();
+		$data_store->read( $customer );
+
+		$this->assertSame( '', $customer->get_shipping_address_2() );
+	}
 }