1
votes

I would like to add a submenu entry under the WooCommerce "Products" admin menu. Does anybody know what the $parent_slug for this menu is?

I can add a submenu item to the "WooCommerce" menu using add_submenu_page and 'woocommerce' for $parent_slug (via the admin_menu hook), but can't seem to figure out what the $parent_slug for the Products menu is...

if ( is_admin() ) {
    add_action( 'admin_menu', 'add_products_menu_entry', 100 );
}

function add_products_menu_entry() {
    add_submenu_page(
        'woocommerce-product', // This is what I can't figure out
        __( 'Product Grabber' ),
        __( 'Grab New' ),
        'manage_woocommerce', // Required user capability
        'ddg-product',
        'generate_grab_product_page'
    );
}

function generate_grab_product_page() {
  // Page generation code will go here
}

WooCommerce Products Admin Menu

enter image description here

1

1 Answers

3
votes

Got it, it was edit.php?post_type=product

if ( is_admin() ) {
    add_action( 'admin_menu', 'add_products_menu_entry', 100 );
}

function add_products_menu_entry() {
    add_submenu_page(
        'edit.php?post_type=product',
        __( 'Product Grabber' ),
        __( 'Grab New' ),
        'manage_woocommerce', // Required user capability
        'ddg-product',
        'generate_grab_product_page'
    );
}

function generate_grab_product_page() {
  echo "<h2>Hello, it worked! :-)</h2>";
}

Thank-you to Derick Rethans / XDebug!