WooCommerce Admin UI Development
Before writing code
Fetch live docs:
- Web-search
site:developer.woocommerce.com settings api for Settings API guide
- Web-search
site:developer.wordpress.org plugins administration-menus for WordPress admin menus
- Web-search
woocommerce admin custom settings page for current patterns
Settings API
WC_Settings_API (For Gateways/Methods)
Payment gateways and shipping methods use WC_Settings_API:
- Define fields in
init_form_fields() as associative array
- Field types:
text, textarea, select, multiselect, checkbox, password, title, decimal, color
- Rendered automatically via
$this->generate_settings_html()
- Saved/loaded automatically via
get_option() / update_option()
WC_Settings_Page (Custom Settings Tabs)
Add a new tab to WooCommerce > Settings:
- Extend
WC_Settings_Page
- Set
$this->id and $this->label
- Implement
get_settings_for_default_section() — return settings array
- Register via
woocommerce_get_settings_pages filter
Settings Field Format
Each field is an array with keys:
id — option name (stored in wp_options)
title — field label
type — text, select, checkbox, textarea, number, sectionend, title
default — default value
desc — description text
options — for select/multiselect
css — inline CSS for the input
Admin Menus
Adding Sub-Menus Under WooCommerce
add_submenu_page( 'woocommerce', $page_title, $menu_title, $capability, $slug, $callback )
Top-Level Menus
add_menu_page() for standalone admin sections — less common for WC extensions.
Capability Checks
manage_woocommerce — WooCommerce admin capability
edit_shop_orders — order management
edit_products — product management
- Always check capabilities in menu and page callbacks
Product Data Panels
Adding Tabs
Filter woocommerce_product_data_tabs:
$tabs['my_tab'] = [
'label' => __( 'My Tab', 'my-plugin' ),
'target' => 'my_tab_data',
'class' => [ 'show_if_simple', 'show_if_variable' ],
'priority' => 60,
];
Adding Panel Content
Action woocommerce_product_data_panels:
- Render HTML inside a
<div id="my_tab_data" class="panel"> matching the tab target
- Use
woocommerce_wp_text_input(), woocommerce_wp_select(), etc.
Saving Panel Data
Action woocommerce_process_product_meta — receives $post_id:
- Sanitize input:
sanitize_text_field( $_POST['my_field'] )
- Save:
$product->update_meta_data( '_my_field', $value ) then $product->save()
Order Admin Customization
Meta Boxes
Add custom meta boxes to the order edit screen:
add_meta_box( $id, $title, $callback, 'woocommerce_page_wc-orders', $context, $priority )
- For HPOS: use screen ID
woocommerce_page_wc-orders (not shop_order)
- For legacy: use post type
shop_order
Order Actions
Filter woocommerce_order_actions to add custom order actions.
Bulk Actions
Filter bulk_actions-edit-shop_order (legacy) or bulk_actions-woocommerce_page_wc-orders (HPOS).
WooCommerce Admin (React-Based)
Analytics & Reports
WooCommerce Admin is a React SPA for:
- Revenue, Orders, Products, Categories, Coupons, Taxes, Downloads reports
- Dashboard with customizable widgets
- Activity panel (orders, reviews, stock)
Extending Analytics
Use @woocommerce/data and @woocommerce/components packages:
- Add custom report pages via
woocommerce_admin_reports_pages filter (PHP)
- Register custom analytics data stores
- Extend existing reports with additional columns
Admin Notices
WooCommerce Admin Notices
WC_Admin_Notices::add_custom_notice( $name, $html ) — persistent notices
wc_admin_notice() helper for one-time notices
admin_notices action for standard WordPress admin notices
Best Practices
- Use WooCommerce Settings API for gateway/method settings
- Use
WC_Settings_Page for custom settings tabs
- Always check capabilities (
manage_woocommerce, edit_products, etc.)
- Use HPOS-compatible screen IDs for order meta boxes
- Sanitize all admin form input before saving
- Use nonces for all admin form submissions
- Localize admin strings with
__() / esc_html__()
Fetch the WooCommerce Settings API docs and WordPress admin handbook for exact field types, hook names, and screen IDs before implementing.
1---2name: woo-admin3description: Build WooCommerce admin interfaces — settings pages, admin menus, product data tabs/panels, order meta boxes, WooCommerce Admin (React analytics), and reports. Use when creating admin-facing configuration or display pages.4---5
6# WooCommerce Admin UI Development
7
8## Before writing code
9
10**Fetch live docs**:
111. Web-search `site:developer.woocommerce.com settings api` for Settings API guide
122. Web-search `site:developer.wordpress.org plugins administration-menus` for WordPress admin menus
133. Web-search `woocommerce admin custom settings page` for current patterns
14
15## Settings API
16
17### WC_Settings_API (For Gateways/Methods)
18
19Payment gateways and shipping methods use `WC_Settings_API`:
20- Define fields in `init_form_fields()` as associative array
21- Field types: `text`, `textarea`, `select`, `multiselect`, `checkbox`, `password`, `title`, `decimal`, `color`
22- Rendered automatically via `$this->generate_settings_html()`
23- Saved/loaded automatically via `get_option()` / `update_option()`
24
25### WC_Settings_Page (Custom Settings Tabs)
26
27Add a new tab to WooCommerce > Settings:
281. Extend `WC_Settings_Page`
292. Set `$this->id` and `$this->label`
303. Implement `get_settings_for_default_section()` — return settings array
314. Register via `woocommerce_get_settings_pages` filter
32
33### Settings Field Format
34
35Each field is an array with keys:
36- `id` — option name (stored in `wp_options`)
37- `title` — field label
38- `type` — `text`, `select`, `checkbox`, `textarea`, `number`, `sectionend`, `title`
39- `default` — default value
40- `desc` — description text
41- `options` — for select/multiselect
42- `css` — inline CSS for the input
43
44## Admin Menus
45
46### Adding Sub-Menus Under WooCommerce
47
48`add_submenu_page( 'woocommerce', $page_title, $menu_title, $capability, $slug, $callback )`
49
50### Top-Level Menus
51
52`add_menu_page()` for standalone admin sections — less common for WC extensions.
53
54### Capability Checks
55
56- `manage_woocommerce` — WooCommerce admin capability
57- `edit_shop_orders` — order management
58- `edit_products` — product management
59- Always check capabilities in menu and page callbacks
60
61## Product Data Panels
62
63### Adding Tabs
64
65Filter `woocommerce_product_data_tabs`:
66```php
67$tabs['my_tab'] = [
68 'label' => __( 'My Tab', 'my-plugin' ),
69 'target' => 'my_tab_data',
70 'class' => [ 'show_if_simple', 'show_if_variable' ],
71 'priority' => 60,
72];
73```
74
75### Adding Panel Content
76
77Action `woocommerce_product_data_panels`:
78- Render HTML inside a `<div id="my_tab_data" class="panel">` matching the tab target
79- Use `woocommerce_wp_text_input()`, `woocommerce_wp_select()`, etc.
80
81### Saving Panel Data
82
83Action `woocommerce_process_product_meta` — receives `$post_id`:
84- Sanitize input: `sanitize_text_field( $_POST['my_field'] )`
85- Save: `$product->update_meta_data( '_my_field', $value )` then `$product->save()`
86
87## Order Admin Customization
88
89### Meta Boxes
90
91Add custom meta boxes to the order edit screen:
92- `add_meta_box( $id, $title, $callback, 'woocommerce_page_wc-orders', $context, $priority )`
93- For HPOS: use screen ID `woocommerce_page_wc-orders` (not `shop_order`)
94- For legacy: use post type `shop_order`
95
96### Order Actions
97
98Filter `woocommerce_order_actions` to add custom order actions.
99
100### Bulk Actions
101
102Filter `bulk_actions-edit-shop_order` (legacy) or `bulk_actions-woocommerce_page_wc-orders` (HPOS).
103
104## WooCommerce Admin (React-Based)
105
106### Analytics & Reports
107
108WooCommerce Admin is a React SPA for:
109- Revenue, Orders, Products, Categories, Coupons, Taxes, Downloads reports
110- Dashboard with customizable widgets
111- Activity panel (orders, reviews, stock)
112
113### Extending Analytics
114
115Use `@woocommerce/data` and `@woocommerce/components` packages:
116- Add custom report pages via `woocommerce_admin_reports_pages` filter (PHP)
117- Register custom analytics data stores
118- Extend existing reports with additional columns
119
120## Admin Notices
121
122### WooCommerce Admin Notices
123
124- `WC_Admin_Notices::add_custom_notice( $name, $html )` — persistent notices
125- `wc_admin_notice()` helper for one-time notices
126- `admin_notices` action for standard WordPress admin notices
127
128## Best Practices
129
130- Use WooCommerce Settings API for gateway/method settings
131- Use `WC_Settings_Page` for custom settings tabs
132- Always check capabilities (`manage_woocommerce`, `edit_products`, etc.)
133- Use HPOS-compatible screen IDs for order meta boxes
134- Sanitize all admin form input before saving
135- Use nonces for all admin form submissions
136- Localize admin strings with `__()` / `esc_html__()`
137
138Fetch the WooCommerce Settings API docs and WordPress admin handbook for exact field types, hook names, and screen IDs before implementing.