WooCommerce Admin UI Development
Before writing code
Fetch live docs:
- Web-search
site:developer.woocommerce.com settings apifor Settings API guide - Web-search
site:developer.wordpress.org plugins administration-menusfor WordPress admin menus - Web-search
woocommerce admin custom settings pagefor 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->idand$this->label - Implement
get_settings_for_default_section()— return settings array - Register via
woocommerce_get_settings_pagesfilter
Settings Field Format
Each field is an array with keys:
id— option name (stored inwp_options)title— field labeltype—text,select,checkbox,textarea,number,sectionend,titledefault— default valuedesc— description textoptions— for select/multiselectcss— 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 capabilityedit_shop_orders— order managementedit_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(notshop_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_pagesfilter (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 noticeswc_admin_notice()helper for one-time noticesadmin_noticesaction for standard WordPress admin notices
Best Practices
- Use WooCommerce Settings API for gateway/method settings
- Use
WC_Settings_Pagefor 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.