Home Forums WoodMart support forum display the product category

display the product category

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #630190

    My WoodMart
    Participant

    Is there a way to display the product category on the cart page and in the popup window? Is it possible?

    Attachments:
    You must be logged in to view attached files.
    #630283

    Hello,

    Sorry to say there is no option in theme settings to show category in the shopping cart widget.

    To show category on cart page add this below code in function.php of the child theme:

    add_filter( 'woocommerce_cart_item_name', 'pk_cart_item_category', 9999, 3 );
    
    function pk_cart_item_category( $name, $cart_item, $cart_item_key ) {
    
       $product = $cart_item['data'];
       if ( $product->is_type( 'variation' ) ) {
          $product = wc_get_product( $product->get_parent_id() );
       }
    
       $cat_ids = $product->get_category_ids();
    
       if ( $cat_ids ) $name .= '<br>' . wc_get_product_category_list( $product->get_id(), ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', count( $cat_ids ), 'woocommerce' ) . ' ', '</span>' );
    
       return $name;
    
    }

    Best Regards

    #630431

    My WoodMart
    Participant

    Great
    You can close the ticket

    #630467

    Most Welcome!!!.

    I’m so happy to hear you are pleased with the Theme and Support. XTEMOS strives to deliver the best customer experience, and it makes our day to hear we have accomplished that.

    We count ourselves lucky to have you as a customer. You can always reach us at any time. We are always here to help you.

    Thanks for contacting us.
    Have a great day.

    Topic Closed.
    Best Regards.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘display the product category’ is closed to new replies.