我缺少一些东西。我看过几篇有关如何更新项目元数据的文章,但我无法让其中任何一篇起作用。我需要获取 item_id 但我不知道该怎么做。
$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
我尝试通过以下方式提取 Item_id
foreach ( $items as $item ) {
$product_id = $item->get_product_id();
$item_id = $item['item_id'];
break;
}
也尝试过这个
foreach ($items as $key => $product ) {
$item_id = $key;
}
叮当猫咪