Get variations IDs from a variable product Code Example
Get variations IDs from a variable product
// (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];