Monday, 28 September 2015

How to make WooCommerce order itemmeta editable in Admin Pane

In WooCommerce the order itemmeta data are not editable

Open wp-admin/edit.php?post_type=shop_order
Click any order to edit it
In the 'Order Items' Section, the meta data are displayed but not editable
When looking at the source code of this section, a div '<div class="view">' can be found as well as a paralleled div '<div class="edit">', but the edit div is hidden. That's why the order itemmeta are not editable here

Tweak the template file to make it editable

Open the template file with the path of 'wp-content/plugins/woocommerce/includes/admin/meta-boxes/views/html-order-item.php'
Search 'div class="view"' and add 'style="display: none;' for the div
Search 'div class="edit"' and remove 'style="display: none;' from this div

Note: WooCommerce do have the logic implementation to process editing the order itemmeta, but the edit div is hidden for some reason and there is no documentation that indicate this trick which caused me a whole day to find it out.