WooCommerce add class name in the list [closed]

There is no particular hook available to deal with classes in products list.
Therefore, we need to edit, “content-product.php” present in, “template” folder of “woocommerce” plugin.

We can add following code:

$product_id = get_the_ID();
$result = wp_get_post_terms($product_id,'product_cat');

    if(!empty($result)){

        $term = '';

        foreach($result as $single_result)
        {
            $term .= ' ' . $single_result->slug;
        }

        $classes[] = $term;
    }

after,

$classes = array(); 

statement.

This will result in the following output:

<ul class="products">
<li class="post-246 product type-product status-publish hentry general first sale instock">
<li class="post-33 product type-product status-publish hentry sale instock">
<li class="post-244 product type-product status-publish hentry general special sale instock">
</ul>

where, “General” and “Special” are categories.

Here I am fetching, product categories slugs and appending it to products class.