3

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 ?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
EmilioSuarez
  • 33
  • 1
  • 3
  • Can you give us the **value** for this **`Product_Serial`** related to a bought product for some **user_id**… As you are trying to get this in **woocommerce order edit pages**, this **value** should contain a **product_id** (related to the generated serials) and should be displayed only if the order contain this bought product. It's important you give us **this value to see how it's formatted**… So please update your question with this details. Without it nobody can help. Thanks – LoicTheAztec Aug 28 '16 at 22:18

2 Answers2

2

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

Sajid anwar
  • 1,194
  • 14
  • 41
0

As coder said there is multiple hooks you can also try this out.

add_action('woocommerce_admin_order_data_after_order_details', 'my_custom_order_manipulation_function');
function my_custom_order_manipulation_function( $orderID ) {
    //dynamic functionalities / static html to display
}

Credits : Add order metadata to WooCommerce admin order overview

Community
  • 1
  • 1
Ashok G
  • 161
  • 2
  • 10