Title: Adding category
Last modified: March 19, 2025

---

# Adding category

 *  Resolved [enricobt](https://wordpress.org/support/users/enricobt/)
 * (@enricobt)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/adding-category-2/)
 * Hi
 * I’m trying to customize request-quote-view.php to replace quantity with product
   category.
 * In the code, I commented out all quantity lines and added these few lines, but
   it doesn’t work.
 *  $_product = wc_get_product( $product_id );
    $categ = $_product->get_categories();
   $term = get_term_by ( ‘name’ , strip_tags($categ), ‘product_cat’ ); echo $term-
   >description; ?>
 * 
   I’m not a PHP expert, so I’m not sure if this is correct, can you help me?Many
   Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [Carlos M](https://wordpress.org/support/users/cjmora/)
 * (@cjmora)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/adding-category-2/#post-18374425)
 * Hi [@enricobt](https://wordpress.org/support/users/enricobt/),
   Although you’re
   editing the `request-quote-view.php` template, you’re actually trying to get 
   the description of a term (product category). This is related to WordPress and
   WooCommerce, not specific to Request a Quote. Please use the support forums appropriately.
   Please note `get_categories()` is deprecated. Instead, you should use `get_category_ids()`.
   Maybe this adjustment could help:`$_product = wc_get_product( $product_id );$
   categories = $_product->get_category_ids();foreach ( $categories as $category_id){
   $term = get_term_by( 'id', $category_id, 'product_cat' );    echo $term->description;}
 *  Thread Starter [enricobt](https://wordpress.org/support/users/enricobt/)
 * (@enricobt)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/adding-category-2/#post-18375011)
 * Hi Carlos
 * many thanks for your help, it worked fine, I had to replace echo $term->description
   with
 * “echo $term->name;”
 * Unfortunately $term->name is a unique string composed of Category Name and Subcategory
   like: “CategorySubacategory”, without any blank space in the middle.
 * I understand now that I should have asked Woocommerce support, but the fact is
   that I was working on a file of this plugin.
   Anyhow thanks again for your help.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding category’ is closed to new replies.

 * ![](https://ps.w.org/yith-woocommerce-request-a-quote/assets/icon-128x128.gif?
   rev=3234570)
 * [YITH Request a Quote for WooCommerce](https://wordpress.org/plugins/yith-woocommerce-request-a-quote/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yith-woocommerce-request-a-quote/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yith-woocommerce-request-a-quote/)
 * [Active Topics](https://wordpress.org/support/plugin/yith-woocommerce-request-a-quote/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yith-woocommerce-request-a-quote/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yith-woocommerce-request-a-quote/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [enricobt](https://wordpress.org/support/users/enricobt/)
 * Last activity: [1 year, 2 months ago](https://wordpress.org/support/topic/adding-category-2/#post-18375011)
 * Status: resolved