Hi @perqedelius
Yes, you can.
Although writing or providing custom code is not within the scope of our support policy, here is an example:
if (is_product_category()) {
global $wp_query;
// get the query object
$cat_obj = $wp_query->get_queried_object();
if($cat_obj) {
$category_name = $cat_obj->name;
$term_id = $cat_obj->term_id;
// Get the count of the products in this category
$product_count = $cat_obj->count;
if($product_count > 0) {
// if the product count is greater than 0, it means this category has products
// load your desired template here
}
}
}If you are still having problems, we recommend asking development questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:
I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.
Thank you!
This worked fine. I will check out the developers channel.
/Perqedelius
Hi @perqedelius,
Glad to hear it – thanks for letting us know!
I’ll mark this thread as resolved now. If you have any further questions, I recommend creating a new thread.
