我目前有一个插件,可以将订购产品的SKU输出为CSV,并且可以正常工作,但是,每订购了可变产品,该sku就会为空。
我看过负责的代码,可以看到它在寻找product_id然后输出get_sku,但是将有条件的product_id更改为variable_id无效,这就是我到目前为止所要做的;
foreach($this->order->get_items() as $item) {
$this->lines[] = $this->addOrderLine($item);
}
public function __construct($item, $order)
{
$this->item = $item;
$this->order = $order;
$this->product = wc_get_product($item->get_product_id());
}
public function getSku()
{
return $this->product->get_sku();
}
任何帮助将不胜感激