WooCommerce – Adding product category to order details table – order-details.php
-
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
- The topic ‘WooCommerce – Adding product category to order details table – order-details.php’ is closed to new replies.