EDITED:
I misunderstood you. This should do it (checked it on my woocommerce test page):
if (!function_exists('shop_attributes_in_loop')) {
function shop_attributes_in_loop(){
global $product;
$attributes = $product->get_attributes();
if(!empty($attributes)){
$attribute_single = array_keys($attributes);
$myArray = array();
echo '<div class="product_attributes">';
foreach ($attribute_single as $attribute => $value) {
$myArray[] = ucfirst($value);
}
echo implode(', ', $myArray).'</div>';
}
}
}
add_action('woocommerce_after_shop_loop_item', 'shop_attributes_in_loop');
This will put your product attributes, if existing, in a div .product_attrributes
. You can easily add a translatable string saying that those are product attributes like
echo esc_html('Product attributes', 'my-theme-name') .'<div class="product_attributes">'
in the first echo
.
$variations = $product->get_available_variations();
? – dingo_d