I’ve taken over my companies WordPress site after the web company we used went bust. I’m not a strong programmer, so bare with me. I’m trying to edit the metadata fields on our WooCommerce admin order page. For example, where it says "_user_handle_rebate", I need it to say "Handle Rebate". I’ve looked for this with a string finder and I can only see this in the order-details.php file, which is not seemingly where this is coded after trying to change the name. Lots of googling has suggested this may be in the functions.php file, but I’m still at a loss of what to look for.
Is there a snippet of code I can add to change this after the fact or do I have to change this value when it is stored. Any advice is much appreciated.
I’ve tried editing the metadata fields in the order-details.php file, but this has no effect on the admin order page. I’ve also tried looking in the functions.php, but to no avail. This is the only code I can find with a string finder:
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order );
echo "<br/>";
if (!empty($item_meta->meta['_user_width'][0]))
echo "Width: ". $item_meta->meta['_user_width'], $item_meta->meta['_user_unit'] ."<br/>";
if (!empty($item_meta->meta['_user_drop'][0]))
echo "Drop: ". $item_meta->meta['_user_drop'], $item_meta->meta['_user_unit'] ."<br/>";
if (!empty($item_meta->meta['_user_fitting'][0]))
echo "Fitting Type: ". $item_meta->meta['_user_fitting'] . "<br/>";
if (!empty($item_meta->meta['_user_pull']))
echo "Pull side: ". $item_meta->meta['_user_pull'] ."<br/>";
if (!empty($item_meta->meta['_user_chain']))
echo "Chain Type: ". $item_meta->meta['_user_chain'] ."<br/>";
if (!empty($item_meta->meta['_user_tilt'][0]))
echo "Tilt side: ". $item_meta->meta['_user_tilt'] ."<br/>";
if (!empty($item_meta->meta['_user_controls'][0]))
echo "Controls: ". $item_meta->meta['_user_controls'] ."<br/>";
if (!empty($item_meta->meta['_user_stack'][0]))
echo "Stack side: ". $item_meta->meta['_user_stack'] ."<br/>";
if (!empty($item_meta->meta['_user_bracket'][0]))
echo "Bracket fitting side: ". $item_meta->meta['_user_bracket'] ."<br/>";
if (!empty($item_meta->meta['_user_opening'][0]))
echo "Control Wand: ". $item_meta->meta['_user_opening'] ."<br/>";
if (!empty($item_meta->meta['_user_frame_colour'][0]))
echo "Frame colour: ". $item_meta->meta['_user_frame_colour'] ."<br/>";
if (!empty($item_meta->meta['_user_operation_type'][0]))
echo "Operation Type: ". $item_meta->meta['_user_operation_type'] ."<br/>";
if (!empty($item_meta->meta['_user_depth'][0]))
echo "Depth: ". $item_meta->meta['_user_depth'] ."<br/>";
if (!empty($item_meta->meta['_user_handle_rebate']))
{
echo "Handle Rebate Location: ". $item_meta->meta['_user_handle_rebate'];
echo '<br/>Measurements: ' . $item_meta->meta['_user_hr_measurements'].' mm';
}
2
Answers
Stumbled on some code of yours @LoicTheAztec from 2021, seems to have done the trick!
In WooCommerce admin single order pages, to change any displayed meta key to a readable label name replacement, use the following:
Code goes in functions.php file of your child theme (or in a plugin). It should work.