简体   繁体   中英

Woocommerce / Wordpress - Add button to Order / Product Page on Admin Panel

I need to add a button and or text to both the order page and product page of the admin panel of woocommerce. They are actually both types of /wp-admin/post.php but evidentally different post types. Is this possible? I have look through the available hooks on the woocommerce list and the only ones I have tried actually put information on the listings page of each.

Just looking for the filter/hook!

Many thanks in advance, sorry for no code samples - not applicable as just looking for an identifier!!

In order to add a custom button to the Woocommerce Order Page (On Admin Page) you need to use add_meta_boxes wordpress action we can then use a filter for shop_order so it only display on the woocommerce orders. So code would look something like this...

add_action( 'add_meta_boxes', 'MY_order_meta_boxes' );
function MY_order_meta_boxes()
{
    add_meta_box(
        'woocommerce-order-YOUR-UNIQUE-REF',
        __( 'The title of my box' ),
        'order_meta_box_YOURCONTENT',
        'shop_order',
        'side',
        'default'
    );
}
function order_meta_box_YOURCONTENT()
{
  echo '<button>New button</button>';
}

You then would want your button to do something, so it is work adding some JS into that last function also. Then you are probably likely to want to use Wordpress AJAX which you can read about and see a demo here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM