doufei4418
2018-06-27 18:39
浏览 109
已采纳

将自定义元数据添加到Woocommerce 3中的管理订单编辑页面

When I send the order to an external delivery service (API), I get the answer: $delivery_order_id = '100678'. In this matter, these data are stored in metadata.

How to display this value in the admin panel Woocommerce?

图片转代码服务由CSDN问答提供 功能建议

当我将订单发送到外部递送服务(API)时,我得到答案: $ delivery_order_id ='100678'在这个问题上,这些数据存储在元数据中。

如何在管理面板中显示此值Woocommerce?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • dongtuo0828 2018-06-27 18:45
    最佳回答

    This can be done using dedicated hooks like woocommerce_admin_order_data_after_order_details this way:

    add_action( 'woocommerce_admin_order_data_after_order_details', 'admin_order_display_delivery_order_id', 60, 1 );
    function admin_order_display_delivery_order_id( $order ){
    
        $delivery_order_id = get_post_meta( $order->get_id(), 'delivery_order_id', true );
    
        $delivery_id = ! empty( $delivery_order_id ) ? $delivery_order_id : '<span style="color:red">' .__('Not yet.') . '</span>';
        echo '<br clear="all"><p><strong>'.__('Delivery Order Id').':</strong> ' . $delivery_id . '</p>';
    }
    

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

    enter image description here

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题