首页 > 解决方案 > 向 Woocommerce 管理订单页面添加新块

问题描述

我想在 Woocommerce 管理订单页面中创建一个自定义表格块。正如您在屏幕截图中看到的那样,我使用了:

add_action( 'woocommerce_admin_order_data_after_order_details', 'vp_admin_order_table' );

我想要的是创建一个单独的块,里面有这个表。

是否有任何操作可以触发订单详细信息和产品列表之间的差距?

在此处输入图像描述

标签: wordpresswoocommercehook-woocommerce

解决方案


试试这个代码:

function op_register_menu_meta_box() {
    add_meta_box(
        'Some identifier of your custom box',
        esc_html__( 'Box Title', 'text-domain' ),
        'render_meta_box',
        'shop_order', // shop_order is the post type of the admin order page
        'normal', // change to 'side' to move box to side column 
        'low' // priority (where on page to put the box)
    );
}
add_action( 'add_meta_boxes', 'op_register_menu_meta_box' );

function render_meta_box() {
    // Metabox content
    echo '<strong>Your awesome content goes here</strong>';
}

请记住在订单页面的“屏幕选项”下将框设置为可见。


进一步阅读:


推荐阅读