prayas prayas - 1 year ago 174
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download