$product = wc_get_product( $product_id ); $variations = $product->get_available_variations(); $variation_ids = wp_list_pluck( $variations, 'variation_id' );
Get an array of variation IDs for a given product ID (visible variations only)
This post brought to you by RocketGeek, ButlerBlog, and the following: