• Hi there,

    I’m attempting to add the product category to the order details section of the order-details.php template file.

    I found nothing about it online, I found solutions to adding custom content but not the category.

    As far as I can see in the code a class is being used to call the item total and get the product id. I was hoping that It would be just as easy to get the product category. I’m not full time developing in PHP so my knowledge is inconsistent. Any advice or pointers in the right direction or even some knowledge from the authors would be really helpful in my current project and my understanding of the plug in and PHP.

    Here’s an example of the code being used to call the name and total products ordered

    foreach( $order->get_items() as $item ) {
    	$_product     = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
    	$item_meta    = new WC_Order_Item_Meta( $item['item_meta'], $_product ); ?> 
    
    	<td class="product-name">
    	<?php
    	if ( $_product && ! $_product->is_visible() )
    	echo apply_filters( 'woocommerce_order_item_name', $item['name'], $item );
    	else
    	echo apply_filters( 'woocommerce_order_item_name', sprintf( '<a href="%s">%s</a>', get_permalink( $item['product_id'] ), $item['name'] ), $item );
    
    	echo apply_filters( 'woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf( '× %s', $item['qty'] ) . '</strong>', $item );

    Thanks for any help in advance

    John

Viewing 1 replies (of 1 total)
  • I have a feeling you are the same John as in this thread on Stackoverflow, but just posting the solution here just in case and as well for others (like me) who encountered the same issue.

    http://stackoverflow.com/questions/24414839/woocommerce-adding-product-category-to-order-details-table

    As I wasn’t sure on how to go about the suggestion of changing the functions.php (where exactly to add what helgatheviking suggested), I changed the order-details.php. Only thing is that on the Check Out page it still doesn’t mention the category (just the product), only when you actually place the order.

    If you or anyone else would have any suggestions on how to do this as well that would be great.

Viewing 1 replies (of 1 total)
  • The topic ‘WooCommerce – Adding product category to order details table – order-details.php’ is closed to new replies.