Update the product visibility in Woocommerce 3 Update the product visibility in Woocommerce 3 wordpress wordpress

Update the product visibility in Woocommerce 3


Since Woocommerce 3 the products visibility is now handled by the 'product_visibility' custom taxonomy for the terms 'exclude-from-catalog' and 'exclude-from-search'… See this thread or this one too.

So you should use instead the WC_Product CRUD setter methods set_catalog_visibility() this way:

// Get an instance of the product variation from a defined ID$child_product = wc_get_product(child_id);// Change the product visibility$child_product->set_catalog_visibility('visible');// Save and sync the product visibility$child_product->save();

This will also update the transients cached data, and will do the trick...