V
V
Vlad Karpov2019-09-03 08:01:04
WordPress
Vlad Karpov, 2019-09-03 08:01:04

How to change the data of a product category and its subcategories in woocommerce?

Hello, I really need your help, there is a store on woocommerce, there are product categories of clothing, cosmetics and shoes with their own subcategories, you need to display a unique text and sidebar for the category and its subcategories.
For example, in the clothing category and its subcategories there will be a sidebar1 and text (clothing to order, our advantages ...)
And for cosmetics and its subcategories, sidebar2 and text (cosmetics from the best manufacturers, natural quality ...)
I hope I expressed myself clearly, a solution without plugin! Help out :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad Karpov, 2019-12-03
@djokerik

you find out the id of the product category (all incoming subcategories will also work), in my case it is ID=384 and ID=376,
you look for these values ​​in the array and if it is there, the condition is met

function woocommerce_product_category_desc() {
  global $product;
  $categor = $product->get_category_ids();
  if (in_array(384, $categor)) {
    //Вывод для первого варианта
  }
  if (in_array(376, $categor)) {
    //Вывод для второго варианта
  }
  
    
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question