I am trying to get the value of a selected product color (attribute slug) in Woocommerce. This works fine with my code for the 'pa_size' and 'pa_mountcolor' attributes but my 'pa_color' attributes has no values. I think that's because in Woocommerce I set this variation attribute as 'any option', Any idea how to get the value of 'pa_color' with this option selected? (I don't want too many variations in Woocommerce because the product images and prices are the same).
foreach($variation_attributes as $attribute_taxonomy => $term_slug ){
// Get product attribute name or taxonomy
$taxonomy = str_replace('attribute_', '', $attribute_taxonomy );
// The label name from the product attribute
$attribute_name = wc_attribute_label( $taxonomy, $product );
// If slug of afmetingen, get the printapi productId
if ($taxonomy == "pa_color"){
echo $term_slug;
$attr_frame_color = $term_slug;
} else if ($taxonomy == "pa_photo_frame"){
//$printapi_hanging_system = $term_slug;
}
}