skip to Main Content

I want to include WC_Admin_List_Table_Products class in my custom plugin so I can re-use woocommerce product admin table in my plugin and customize the actions and buttons on different page. How I can do that? I have tried different ways as.

    include_once( WP_PLUGIN_DIR . '/woocommerce/include/admin/list-tables/class-wc-admin-list-table-products.php' );
    $wc_list_table = new WC_Admin_List_Table_Products();

Even using the plugin_dir_path.

    include_once plugin_dir_path('woocommerce/include/admin/list-tables/class-wc-admin-list-table-products.php');
    $wc_list_table = new WC_Admin_List_Table_Products();

Both are not working at all.

2

Answers


  1. Using plugin_dir_path will not work as plugin_dir_path will return current plugin file or directory path. Replace below line with your line

    include_once( WP_PLUGIN_DIR . '/woocommerce/includes/admin/list-tables/class-wc-admin-list-table-products.php' );
    

    You have made small mistake in writting directory name of ‘include‘. Correct directory name is ‘includes‘.

    Login or Signup to reply.
  2. You should use it like this:

    require_once( WP_PLUGIN_DIR . '/woocommerce/includes/admin/list-tables/class-wc-admin-list-table-products.php' );
    
    class Extended_WC_Admin_List_Table_Products extends Extended_WP_List_Table {
    
    }
    

    and then call your new class in the right location:

    $wc_list_table = new Extended_WC_Admin_List_Table_Products(); 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search