I have a couple of order item meta details that I would not like the customer to see (on the view orders page under account info). I have found a filter that will remove this data from the ADMIN (where I would still like to see it), but can’t find a similar filter to remove it from the FRONT END (where it should be hidden).
Here is the code that will (uselessly, for me) remove it from the back end admin:
add_filter( 'woocommerce_hidden_order_itemmeta', 'add_hidden_order_items' );
function add_hidden_order_items( $order_items ) {
$order_items[] = 'paid_already';
$order_items[] = 'variation_sku';
// and so on...
return $order_items;
}
Save the values with an underscore prefix, that way it won’t be displayed, just saved. Like so:
if you want to hide some items meta from front end order view, you will need to override
order-details-item.php
woocommerce template file.I recommend you: Overriding woocommerce templates via a Theme method, copying templates woocommerce folder to your active theme (or child theme better) and renaming it “woocommerce”.
Once copied in that woocommerce folder (inside your active theme), you will find
order-details-item.php
inorder
subfolder.In line 36 of
order-details-item.php
you will find this:You can change this adding a conditional like:
I am not sure of the veracity of this conditional and can’t test it. You may be obliged to change it a bit…
just for information, function display_item_meta() works this way:
References:
templates/order/order-details-item.php
use ” _ ” before order item meta meta_key it will be hide automatically
Well, it ended up being much easier than I was supposing, the template actually already puts out a class with the name of my item meta, so I just hid it in the css like so:
While it would be nice to know how to prevent these item meta from ever being output, I can live with this as a solution.
Dealing with item meta data, I’m simply hiding the item meta data from the cart using CSS: