prayas prayas - 3 months ago 46
PHP Question

Fetch child products in grouped products woocommerce

I want to fetch child product ids of a parent grouped product, how to do that,
earlier woocommerce saves the child array in

table as key to be
but the recent update has changed the way it saves to the database, plz help me, how can I fetch child products from parent product in grouped products.


Use the get_children() method in the WC_Product_Grouped class.

$product_id = 8; // ID of parent product
$product = get_product( $product_id );
$children = $product->get_children();

It should return an array of product IDs.