• 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

    (@cjmora)

    Hi @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

    (@enricobt)

    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)
  • You must be logged in to reply to this topic.