dcolumbus
dcolumbus

Reputation: 9714

WooCommerce: Adding Order Item Meta Data That's Hidden

I was under the impression that if you add an underscore to your meta_key, it would be hidden from the Admin and subsequently the Order Receipts, etc.

But, mine are showing? I don't understand what's going on...

meta_key: _testing_this, meta_value: asdasdasd

How do I added order item meta without it showing up?

Upvotes: 0

Views: 1573

Answers (2)

dcolumbus
dcolumbus

Reputation: 9714

The answer is to serialize the data you want to be hidden.

Upvotes: 0

Damien
Damien

Reputation: 1478

If I am understanding correctly, to hide order metadata, you could use the existing hook Hidden Order Item Meta.

You could possibly add this to your functions.php or wherever you are storing your customizations:

add_filter( 'woocommerce_hidden_order_itemmeta', 'add_your_hidden_order_items' );
function add_your_hidden_order_items( $order_items ) {
    $order_items[] = '_testing_this';
    // any other entries you want to hide..
    return $order_items;
}

I'm not sure this will remove the meta from the admin view. It may be worth while looking at this post about customizing the order meta box.

I hope this helps.

Upvotes: 2

Related Questions