Commit 105a726a1e7 for woocommerce
commit 105a726a1e7f4e8079b391f9dd2ded0da5128fc9
Author: Brian Coords <bacoords@gmail.com>
Date: Tue Jul 21 15:08:47 2026 -0700
Docs: Fix dynamic settings hook documentation (#66832)
Fix dynamic settings hook documentation
diff --git a/docs/extensions/settings-and-config/README.md b/docs/extensions/settings-and-config/README.md
index 8a9b0c64f4c..95791e622be 100644
--- a/docs/extensions/settings-and-config/README.md
+++ b/docs/extensions/settings-and-config/README.md
@@ -33,7 +33,7 @@ There are three core responsibilities of this class:
- Render them through `admin_options()`.
- Hook `process_admin_options()` to the update hook that matches your context.
-For `process_admin_options()`, those contexts could be `woocommerce_update_options_payment_gateways` for a payment gateway, or `woocommerce_update_options_shipping_methods` for a shipping method.
+For `process_admin_options()`, use the dynamic update hook for the context and append the gateway or shipping method ID. Payment gateways use `woocommerce_update_options_payment_gateways_{$gateway_id}`, while shipping methods use `woocommerce_update_options_shipping_{$shipping_method_id}`.
The API lets you control field placements without presupposing a location. However, this means it doesn't create a settings page for you, so you'll need to register that separately if needed. For extensions that fit within payment or shipping contexts, you are extending the same class that WooCommerce's own gateways use.
@@ -44,7 +44,7 @@ class My_Extension_Settings extends WC_Settings_API {
$this->init_form_fields();
$this->init_settings();
add_action(
- 'woocommerce_update_options_' . $this->id,
+ 'woocommerce_update_options_payment_gateways_' . $this->id,
array( $this, 'process_admin_options' )
);
}
@@ -113,7 +113,7 @@ Rather than creating a whole new page, you can add a section beneath an existing
- `woocommerce_get_sections_{tab}` registers the section.
- `woocommerce_get_settings_{tab}` supplies its fields.
-The `{tab}` portion of each filter corresponds to the tab you want to extend. For instance, `products` targets the **Products** tab, while `accounts` targets **Account and Privacy**.
+The `{tab}` portion of each filter corresponds to the settings page ID for the tab you want to extend. For instance, `products` targets the **Products** tab, while `account` targets **Accounts & Privacy**.
Placing settings under an existing tab keeps the admin area organized and means merchants find your extension's options in an understandable context. The limit is that linking to your section from documentation or onboarding flows requires a URL with both a tab and a section parameter rather than a page URL you control.
diff --git a/docs/extensions/settings-and-config/settings-api.md b/docs/extensions/settings-and-config/settings-api.md
index a7a581d84ba..d381ff757d1 100644
--- a/docs/extensions/settings-and-config/settings-api.md
+++ b/docs/extensions/settings-and-config/settings-api.md
@@ -86,16 +86,16 @@ This will output your settings in the correct format.
## Saving your settings
-To have your settings save, add your class's `process_admin_options` method to the appropriate `_update_options_` hook. For example, payment gateways should use the payment gateway hook:
+To have your settings save, add your class's `process_admin_options` method to the appropriate `_update_options_` hook. The hook includes the gateway or shipping method ID. For example, payment gateways should use:
```php
-add_action( 'woocommerce_update_options_payment_gateways', array( $this, 'process_admin_options' ) );
+add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
```
-Other types of plugins have similar hooks:
+Shipping methods use:
```php
-add_action( 'woocommerce_update_options_shipping_methods', array( $this, 'process_admin_options' ) );
+add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
```
## Loading your settings