Hi. I what to share with you a small code that helped me to get all product variantion ID from Woocommerce.

I used this script to get a meta data used from those product variations:

$query = [
    'post_parent' => "id of the product", ///number format
    'post_status' => 'publish',
    'post_type' => ['product_variation'],
    'posts_per_page' => -1,

$result = [];
$wc_query = new WP_Query($query);
foreach($wc_query->posts AS $key => $value){
    $metaatribute = get_post_meta($value->ID,"atributemeta",true);
You might find interesting:   How to Add WooCommerce Custom Text Field for all Variations


Please enter your comment!
Please enter your name here