T
T
tomas_7492022-01-09 23:16:32
WooCommerce
tomas_749, 2022-01-09 23:16:32

How to add product category name to woocommerce card?

Hello ! I don't know much woocommerce, but the order needs to be closed. I don't know how to add product category output to the card. I have not yet dealt with the "shortcuts" new and sale, but in advance it would be nice to hint at the correct implementation. I hope everyone will be understanding. Thank you)61db4297f101f700340409.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Litvinenko, 2022-01-10
@tomas_749

Discount out of the box, the category is lower, perhaps a different priority, the inscription New needs to be understood on what it depends, there doesn’t seem to be such a box, then a custom field

add_action( 'woocommerce_before_shop_loop_item_title', 'custom_show_product_cat', 30 );

function custom_show_product_cat() {
  global $product;
    echo wc_get_product_category_list( $product->get_id(), ', ', '<div class="product-cat">' . _n( 'Category:', 'Categories:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</div>' ); 
}

G
Genrih777, 2022-01-10
@Genrih777

The novelty and sale is set in the topic. Go to theme settings and dig around there. Of course, you can get into the code of the theme itself, but I did this through banal settings)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question