Commit 0f7de959fbb for woocommerce

commit 0f7de959fbb55157b50b10160a345b9db62f3710
Author: Albert Juhé Lluveras <contact@albertjuhe.com>
Date:   Fri Sep 18 16:07:34 2026 +0200

    Customer Account: fall back to 'mystery' if WP default avatar is 'blank' (#68880)

    * Customer Account: fall back to 'mystery' if WP default avatar is 'blank'

    * Add changelog

    * Fix code structure

    * Add test

    * Make it so 'avatar_default' is reset between tests

diff --git a/plugins/woocommerce/changelog/fix-customer-account-no-blank-avatar b/plugins/woocommerce/changelog/fix-customer-account-no-blank-avatar
new file mode 100644
index 00000000000..cb5f0808c44
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-customer-account-no-blank-avatar
@@ -0,0 +1,5 @@
+Significance: patch
+Type: fix
+Comment: Customer Account: fall back to 'mystery' if WP default avatar is 'blank'
+
+
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/CustomerAccount.php b/plugins/woocommerce/src/Blocks/BlockTypes/CustomerAccount.php
index 185f459f903..8cbb2345596 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/CustomerAccount.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/CustomerAccount.php
@@ -360,10 +360,15 @@ class CustomerAccount extends AbstractBlock {

 		$user_id = get_current_user_id();
 		if ( $user_id ) {
+			$avatar_default = get_option( 'avatar_default', 'mystery' );
+			if ( 'blank' === $avatar_default ) {
+				$avatar_default = 'mystery';
+			}
+
 			$avatar = get_avatar(
 				$user_id,
 				48,
-				'',
+				$avatar_default,
 				'',
 				array(
 					'class' => 'wc-block-customer-account__avatar',
diff --git a/plugins/woocommerce/tests/php/src/Blocks/BlockTypes/CustomerAccountTest.php b/plugins/woocommerce/tests/php/src/Blocks/BlockTypes/CustomerAccountTest.php
index 3a833e3afb8..dc80a54f385 100644
--- a/plugins/woocommerce/tests/php/src/Blocks/BlockTypes/CustomerAccountTest.php
+++ b/plugins/woocommerce/tests/php/src/Blocks/BlockTypes/CustomerAccountTest.php
@@ -25,13 +25,21 @@ class CustomerAccountTest extends WP_UnitTestCase {
 	 */
 	private $original_show_avatars;

+	/**
+	 * Original avatar_default option value.
+	 *
+	 * @var mixed
+	 */
+	private $original_avatar_default;
+
 	/**
 	 * Set up test fixtures.
 	 */
 	public function setUp(): void {
 		parent::setUp();
-		$this->user_id               = $this->factory->user->create();
-		$this->original_show_avatars = get_option( 'show_avatars' );
+		$this->user_id                 = $this->factory->user->create();
+		$this->original_show_avatars   = get_option( 'show_avatars' );
+		$this->original_avatar_default = get_option( 'avatar_default' );
 		update_option( 'show_avatars', 1 );
 	}

@@ -43,6 +51,7 @@ class CustomerAccountTest extends WP_UnitTestCase {
 		wp_set_current_user( 0 );
 		wp_delete_user( $this->user_id );
 		update_option( 'show_avatars', $this->original_show_avatars );
+		update_option( 'avatar_default', $this->original_avatar_default );
 		parent::tearDown();
 	}

@@ -115,6 +124,22 @@ class CustomerAccountTest extends WP_UnitTestCase {
 		$this->assertStringNotContainsString( 'custom-avatar.jpg', $markup );
 	}

+	/**
+	 * @testdox Should fall back to the mystery avatar when the WP default avatar is blank.
+	 */
+	public function test_falls_back_to_mystery_avatar_when_default_is_blank(): void {
+		wp_set_current_user( $this->user_id );
+		update_option( 'avatar_default', 'blank' );
+
+		$markup = $this->render_customer_account(
+			'{"iconClass":"wc-block-customer-account__account-icon"}'
+		);
+
+		$this->assertStringContainsString( 'wc-block-customer-account__avatar', $markup );
+		$this->assertStringContainsString( 'd=mm', $markup );
+		$this->assertStringNotContainsString( 'd=blank', $markup );
+	}
+
 	/**
 	 * Data provider for displayStyle attribute tests.
 	 *