How to display Woocommerce Category image?

To display a category image in WooCommerce, you can use the woocommerce_subcategory_thumbnail hook in your theme's functions.php file. This hook is used to display the category image on the shop page, and it takes the category object as a parameter. Here is an example of how to use this hook:

<?php

function display_category_image($category)
{
  $thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
  $image = wp_get_attachment_url($thumbnail_id);
  if ($image) {
    echo '<img src="' . $image . '" alt="' . $category->name . '" />';
  }
}
add_action('woocommerce_subcategory_thumbnail', 'display_category_image');

Watch a course Learn object oriented PHP

This code will display the category image on the shop page, next to the category name. Note: This code snippet assumes you have set the category image while creating/editing the category in the backend.