Commit fca84aa428f for woocommerce
commit fca84aa428f795f8c367f41470658d357a9113c8
Author: Vladimir Reznichenko <kalessil@gmail.com>
Date: Mon Aug 10 13:37:36 2026 +0200
[Fix] "Your business location does not match your store location" warning on Payments setting page (#67494)
Explicitly initialize the admin setting via admin_init (restore accidental coupling behavior).
diff --git a/plugins/woocommerce/changelog/fix-67461-settings-payments-page-notice b/plugins/woocommerce/changelog/fix-67461-settings-payments-page-notice
new file mode 100644
index 00000000000..56013d70648
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-67461-settings-payments-page-notice
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fixed admin settings initialization.
diff --git a/plugins/woocommerce/includes/class-woocommerce.php b/plugins/woocommerce/includes/class-woocommerce.php
index 725bd86b7a9..156645c37f6 100644
--- a/plugins/woocommerce/includes/class-woocommerce.php
+++ b/plugins/woocommerce/includes/class-woocommerce.php
@@ -345,7 +345,13 @@ final class WooCommerce {
add_action( 'deactivated_plugin', array( $this, 'deactivated_plugin' ) );
add_action( 'woocommerce_installed', array( $this, 'add_woocommerce_inbox_variant' ) );
add_action( 'woocommerce_updated', array( $this, 'add_woocommerce_inbox_variant' ) );
+
+ // Originating from https://github.com/woocommerce/woocommerce/pull/11082 (WC_API::register_wp_admin_settings(), July 2016),
+ // the settings were intended for REST context only. By chance, admin pages relied on unconditional rest_preload_api_request calls,
+ // that triggered rest_api_init as a side effect, and over time admin code bound to these settings as well.
+ add_action( 'admin_init', array( $this, 'register_wp_admin_settings' ) );
add_action( 'rest_api_init', array( $this, 'register_wp_admin_settings' ) );
+
add_action( 'woocommerce_installed', array( $this, 'add_woocommerce_remote_variant' ) );
add_action( 'woocommerce_updated', array( $this, 'add_woocommerce_remote_variant' ) );
add_action( 'woocommerce_newly_installed', 'wc_set_hooked_blocks_version', 10 );
@@ -1536,6 +1542,11 @@ final class WooCommerce {
* @return void
*/
public function register_wp_admin_settings() {
+ // Avoid double-loading in admin caused by rest_preload_api_request calls (e.g. analytics page).
+ if ( doing_action( 'rest_api_init' ) && did_action( 'admin_init' ) ) {
+ return;
+ }
+
$pages = WC_Admin_Settings::get_settings_pages();
foreach ( $pages as $page ) {
new WC_Register_WP_Admin_Settings( $page, 'page' );
diff --git a/plugins/woocommerce/tests/php/includes/class-woocommerce-test.php b/plugins/woocommerce/tests/php/includes/class-woocommerce-test.php
index b77c9a1de94..bb1f9721f06 100644
--- a/plugins/woocommerce/tests/php/includes/class-woocommerce-test.php
+++ b/plugins/woocommerce/tests/php/includes/class-woocommerce-test.php
@@ -167,6 +167,14 @@ class WooCommerce_Test extends \WC_Unit_Test_Case {
$this->assertTrue( WC()->is_store_api_request(), 'A ?rest_route=//wc/store/ request with repeated leading slashes should be detected as Store API.' );
}
+ /**
+ * @testdox Settings registration is hooked to both admin_init and rest_api_init to support direct PHP and REST consumption.
+ */
+ public function test_register_wp_admin_settings_hooked_to_admin_init_and_rest_api_init(): void {
+ $this->assertSame( 10, has_action( 'admin_init', array( WC(), 'register_wp_admin_settings' ) ) );
+ $this->assertSame( 10, has_action( 'rest_api_init', array( WC(), 'register_wp_admin_settings' ) ) );
+ }
+
/**
* @testdox Should load WooCommerce includes in post editor load actions.
*/