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 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数