且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从 woocommerce 的已完成订单中删除特定产品?

更新时间:2023-11-30 07:51:03

我自己找到了答案.我使用下面的代码并且它有效.

I found the answer myself. I use the code below and it worked.

$order = wc_get_order(35);
foreach ($order->get_items() as $item_id => $item) {
  if ($item_id == 3) {
    wc_delete_order_item($item_id);
  }
}