Det visar sig att de är lagrade i ett serialiserat fält.
$attribute_name = 'my-attribute';
$attribute_value = 'cupcakes';
$serialized_value = serialize( 'name' ) . serialize( $attribute_name ) . serialize( 'value' ) . serialize( $attribute_value );
$args = array(
'post_type' => 'product',
'post_status' => 'any',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_product_attributes',
'value' => $serialized_value,
'compare' => 'LIKE',
),
),
);
$query = new WP_Query( $args );
$products = $query->get_posts();
//neat little array of product objects (not the full product object,
//just data that came from query. Can use wordpress loop on $query or
//wc_get_product(--pass product ID here--)