How to add product category name on order page in admin?

In this tutorial we’ll learn how to add product category name on order page in admin side.

First of all we need to place an order if any haven’t played already.

To place an order follow the following steps.

First of all add a product to cart by clicking on add to cart button.

After that, move to cart by clicking on view cart link.

woocommerceFrom cart page click on proceed to checkout button.

woocommerceAfter that place order by clicking on place order button.

woocommerceNow if you go to backend and look into orders under woocommerce tab, you’ll see the newly placed order there.

woocommerceNow, if you look into order details you’ll see there is no category name listed under.

woocommerceNow we need to display category name for products here as well.

To do this add the following lines of code at the end of your theme’s functions.php file:

add_action('woocommerce_before_order_itemmeta','woocommerce_before_order_itemmeta',10,3);

 

function woocommerce_before_order_itemmeta($item_id, $item, $product){

   echo '<p>'.get_the_term_list($product->id, 'product_cat').'</p>';

}

You can access the functions.php file here:

woocommerceSave the file by clicking on update file button after placing the above code.

Now if you move to an order from backend again you’ll see category name listed under products in order.

woocommerceCHEERS J

Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

1 thought on “How to add product category name on order page in admin?”

Leave a Comment

Your email address will not be published. Required fields are marked *