📜  从可变产品中获取变体 ID - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:53.494000             🧑  作者: Mango

代码示例1
// (if needed) Get an instance of the WC_product object (from a dynamic product ID)
$product = wc_get_product($product_id);

// Get children product variation IDs in an array
$children_ids = $product->get_children();

// Get the first ID value
$children_id = reset($children_ids); 
// or 
$children_id = $children_ids[0];