Você está visualizando atualmente WooCommerce: Item Custom Field @ Edit Order Page

WooCommerce: Item Custom Field @ Edit Order Page

  • Autor do post:
  • Categoria do post:Woocommerce
  • Tempo de leitura:4 minutos de leitura

Alright, this title may not really help you understand what I mean, so let’s put it in another way. When, as an administrator, you edit an order and are in the Order Items table, you have the chance to edit the item quantity, subtotal and discounted price (see screenshot below).

Now, what if you also want to have the freedom to display and edit another custom field, so that it is saved inside the order once you hit the “Save” button?

This could be useful for custom setups – for example let’s imagine the admin has the necessity to also define the “shipped quantity”, so that they know exactly if a specific order has been entirely fulfilled or requires a second shipment to get completed.

Either way, see the screenshot below, play with the snippet, and see how it goes. Enjoy!

Here’s a brand new editable column I was able to add to the Edit Order page inside the Order Items table. It works exactly in the same way as the “Qty” field, except that it is a custom field.

PHP Snippet: Add Custom Column to Item Table @ WooCommerce Edit Order Page

/** * @snippet Custom Order Items Column @ Admin * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @compatible WooCommerce 7 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ add_action( ‘woocommerce_admin_order_item_headers’, ‘bbloomer_admin_order_item_headers’ ); function bbloomer_admin_order_item_headers( $order ) { echo ‘

Qty Shipped

‘; } add_action( ‘woocommerce_admin_order_item_values’, ‘bbloomer_admin_order_item_values’, 9999, 3 ); function bbloomer_admin_order_item_values( $product, $item, $item_id ) { if ( $product ) { $shipped = $item->get_meta( ‘order_item_shipped’ ) ? $item->get_meta( ‘order_item_shipped’ ) : 0; echo ‘

x ‘ . $shipped . ‘