douluo1330 2016-08-28 18:16
浏览 75
已采纳

在Woocommerce订单详细信息管理区域中显示自定义数据

When a User Buys a Product he can generate up to 3 Serial Keys for his Product. This works fine so far. The User can see his Serials always in "my account" The Data gets stored in the Database: Table=Usermeta Meta=Product_Serial So from a Users Perspective evrything works fine but from the Admin Perspective not because the admin can´t see how much Serials the Customer has created and also he cant see the Serials the User is using.

Now I have created a Custom Field in the Theme functions.php with this code:

add_action( 'add_meta_boxes', 'add_meta_boxes' );
function add_meta_boxes()
{
    add_meta_box(
        'woocommerce-order-my-custom',
        __( 'Order Custom' ),
        'order_my_custom',
        'shop_order',
        'side',
        'default'
    );
}

But from here I don't know how to read out the Serial Key so the admin can see it. :( Any ideas ?

  • 写回答

2条回答 默认 最新

  • dongyuan6949 2016-08-29 07:51
    关注

    May be i am displaying data in wrong place in your order detail page. But you can check there is multipe hook avilable for this woocommerce/inculdes/admin/meta-boxes-/view/html-order-items.php.

    I just take one this hook. Please add this code in functions.php

    function my_function_meta_deta() {
        echo "I am here";
    }
     add_action( 'woocommerce_admin_order_totals_after_refunded','my_function_meta_deta', $order->id );
    

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器