在woocommerce的管理訂單列表頂部添加一個(gè)按鈕
Add a button on top of admin orders list in woocommerce(在woocommerce的管理訂單列表頂部添加一個(gè)按鈕)
本文介紹了在woocommerce的管理訂單列表頂部添加一個(gè)按鈕的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
限時(shí)送ChatGPT賬號(hào)..
我一直在努力尋找一個(gè)鉤子,讓我可以在 woocommerce 管理訂單頁(yè)面"的頂部添加一個(gè)按鈕,但到目前為止沒(méi)有成功.我找到了將操作按鈕添加到操作列以及每個(gè)訂單頁(yè)面內(nèi)的掛鉤……但不是我現(xiàn)在需要的位置.
如果沒(méi)有鉤子,那么另一種方法.
更具體地說(shuō),我附上了一張我所指的地方的圖片
有什么建議嗎?
解決方案
因?yàn)檫@與 Wordpress 相關(guān),而不是特定于 Woocommerce,因?yàn)橛唵沃皇且环N自定義帖子類型.因此以下代碼將在現(xiàn)有字段和按鈕之后的頂部區(qū)域顯示一個(gè)自定義按鈕:
add_action( 'manage_posts_extra_tablenav', 'admin_order_list_top_bar_button', 20, 1 );功能 admin_order_list_top_bar_button( $which ) {全球 $typenow;if ( 'shop_order' === $typenow && 'top' === $which ) {?><div class="alignleft 動(dòng)作自定義"><button type="submit" name="custom_" style="height:32px;"class="button" value=""><?php回聲 __( '自定義', 'woocommerce');?></按鈕>
<?php}}
代碼位于活動(dòng)子主題(或主題)的 function.php 文件中.經(jīng)過(guò)測(cè)試并有效.
<小時(shí)>
繼續(xù):在woocommerce管理訂單頁(yè)面中的自定義按鈕點(diǎn)擊上運(yùn)行一個(gè)功能
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 add action buttons to the action column, as well as inside each orders page ... but not where I need now.
If there is no hook, then an alternative approach.
More specifically, I attach an image with the place I am referring to
Any suggestions?
解決方案
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 ) {
?>
<div class="alignleft actions custom">
<button type="submit" name="custom_" style="height:32px;" class="button" value=""><?php
echo __( 'Custom', 'woocommerce' ); ?></button>
</div>
<?php
}
}
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
這篇關(guān)于在woocommerce的管理訂單列表頂部添加一個(gè)按鈕的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!