I am missing something. I have seen several articles about how to update an items meta data but I can't get any one of them to work. I need to get the item_id but I can't figure out how to do that.
$your_phone = $item->get_meta('dinner_phone'); // 1115559999
$update_phone = wdc_format_phone($your_phone); // comes back (111) 555-9999
wc_update_order_item_meta($item_id,'dinner_phone', $update_phone); //I want to update with new format
$new_phone = $item->get_meta('dinner_phone'); // doesn't work I still get 1115559999
I have tried to pull the Item_id by the following
foreach ( $items as $item ) {
$product_id = $item->get_product_id();
$item_id = $item['item_id'];
break;
}
Also tried this
foreach ($items as $key => $product ) {
$item_id = $key;
}