Add a button on top of admin orders list in woocommerce

后端 未结 1 1190
猫巷女王i
猫巷女王i 2020-12-19 22:34

I have been struggling to find a hook that allows me to add a button to the top of the woocommerce admin \"orders page\", but so far unsuccessfully. I have found hooks to ad

1条回答
  •  悲哀的现实
    2020-12-19 23:09

    Because this is related to Wordpress and not specific to Woocommerce as Orders are just a custom post type. so the following code will display a custom button on the top zone just after existing fields and buttons:

    add_action( 'manage_posts_extra_tablenav', 'admin_order_list_top_bar_button', 20, 1 );
    function admin_order_list_top_bar_button( $which ) {
        global $typenow;
    
        if ( 'shop_order' === $typenow && 'top' === $which ) {
            ?>
            

    Code goes in function.php file of your active child theme (or theme). Tested and works.


    Continuation: Run a function on custom button click in woocommerce admin order page

    0 讨论(0)
提交回复
热议问题