简体   繁体   English

Woocommerce / Wordpress - 在管理面板上添加按钮到订单/产品页面

[英]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. 我需要在woocommerce管理面板的订单页面和产品页面上添加一个按钮和/或文本。 They are actually both types of /wp-admin/post.php but evidentally different post types. 它们实际上是/wp-admin/post.php两种类型,但是明显不同的帖子类型。 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. 我查看了woocommerce列表中可用的钩子,我尝试过的唯一一个实际上将信息放在每个列表页面上。

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. 为了自定义按钮添加到Woocommerce订购页面(在管理页面),你需要使用add_meta_boxes WordPress的行动,那么我们就可以使用过滤器shop_order所以它只能在woocommerce订单显示。 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. 然后你会希望你的按钮做一些事情,所以将一些JS添加到最后一个函数中也是如此。 Then you are probably likely to want to use Wordpress AJAX which you can read about and see a demo here . 然后你可能想要使用Wordpress AJAX,你可以阅读并在这里看到一个演示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在woocommerce管理订单页面中添加产品属性或自定义字段 - Add product attribute or custom field in woocommerce admin order page WooCommerce - 如何在管理订单页面中向产品列表添加列 - WooCommerce - How to add column to product list in admin order page 如何在产品页面上添加带有价格的单选按钮? WordPress woocommerce - How to add a radio button with price on product page? WordPress woocommerce 在单个产品页面/ Wordpress / Woocommerce中禁用Ajax添加到购物车按钮 - Disable ajax for add to cart button in single product page / Wordpress / Woocommerce 如何在WordPress管理面板中的WooCommerce产品列表中添加复选框列以使用Ajax更新元值 - How to add checkbox column in WooCommerce product listing in WordPress admin panel to update meta value with ajax 如何在woocommerce管理订单详细信息页面上添加操作按钮 - How to add action button on woocommerce admin order detail page 将产品数据添加到 WooCommerce 管理订单预览 - Add product data to WooCommerce admin order preview Woocommerce / Wordpress添加按钮到页面 - Woocommerce / Wordpress add button to page WooCommerce 为重新计算按钮添加订单管理挂钩 - WooCommerce add order admin hook for recalculate button WooCommerce:将自定义 Metabox 添加到管理订单页面 - WooCommerce : Add custom Metabox to admin order page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM