We already saw how to show product categories in the Cart, how to display a category in the Shop page, but we never talked about showing ALL the product’s categories in the Shop / Category / Tag / Loop pages.
On top of that, we’ll also study the wc_get_product_category_list() function again, which is a super useful shortcut to get all the categories for a given product. Enjoy!
PHP Snippet: Show Product Categories’ Links @ Shop Loop Item
/**
* @snippet WooCommerce: Product Categories @ Shop Items
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @testedwith WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_show_product_categories', 9 );
function bbloomer_show_product_categories() {
global $product;
echo wc_get_product_category_list( $product->get_id(), ', ', '<p>', '</p>' );
}