I would like to modify the tables with line-itemed product info for 1) Order Details 2) Cart 3) Checkout Review 4) Order Email. Specifically, I would like to add a custom field (e.g. via get_post_meta) just below the product variation list.

I'm confused, however, on the difference between woocommerce_add_order_item_meta and woocommerce_order_items_table. If I'm not mistaken, woocommerce_add_order_item_meta would add a row in the database for the respective order and woocommerce_order_items_table deals with rendering the table output. If this is incorrect, please let me know.

So, if I'm not totally mistaken I'd have two options:

1) edit...

  • ~/wp-content/plugins/woocommerce/templates/order/order-details-item.php
  • ~/wp-content/plugins/woocommerce/templates/emails/email-order-items.php
  • ~/wp-content/plugins/woocommerce/templates/cart/cart-item-data.php

...and just add my field in via template files

-- or --

2) there's some hook that I'm unable to understand that would allow me to insert my field without touching the template files

So, to try to get things concise: is there action/filter hook that will allow me to, effectively, add a table cell to order/cart/email item tables?

Thanks in advance!


woocommerce_add_order_item_meta will allow you to hook into the order creation process, its fired right after an error is checked on an item, so you know the item is legit. You could implement this with your get_post_meta function.

As for the the meta display, there are a couple things going on. The email and the order details page are both displaying an order, so when it comes to their order display they both use the WC_Order_Item_Meta class display function, in this function is an action called woocommerce_order_items_meta_display which you can use to display your order item meta (use some variation of echo). The cart, on the other hand, is showing a cart item. Woocommerce treats it differently than the former, in this case you'll need the WC_Cart function called get_item_data where you will see a filter called woocommerce_get_item_data. This filter allows you to manipulate the item data before it is passed to the view for display.

Take a look at those links, you'll possibly need to reference the action or filter arguments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.