# Show or hide ACF fields by WooCommerce order status

URL: https://wp24x7.com/show-hide-acf-field-woocommerce-order-status/
Updated: 2026-11-29
Type: blog post

> To show an extra field on the WooCommerce order screen only at certain order statuses, use a WooCommerce hook that checks the order status in code, because the old ACF Post Status location rule no longer works on stores using High-Performance Order Storage. This guide explains why, gives portable code using the order object API, and covers legacy storage, permissions and common problems.

## Key facts

- For: WooCommerce store owners and developers
- Problem: ACF Post Status rules fail with HPOS order screens
- Reliable method: woocommerce_admin_order_data_after_order_details plus a save hook
- Storage: use $order->get_meta() and update_meta_data(), not post functions
- Security: capability check and sanitised input on save
- Check HPOS: WooCommerce, Settings, Advanced, Features
- Help: WooCommerce experts and plugin development

A common request is an extra field on the WooCommerce order screen that appears only at certain stages: a tracking reference once an order is "Processing", or a refund note once it is "Refunded". The old approach was to use ACF's location rule **Post Status**. **On stores using High-Performance Order Storage that rule no longer works, so the dependable method is a WooCommerce hook that checks the order's status in code.**

Test on a staging copy and back up before you add code. Put the snippet in a small custom plugin or a child theme.

> **Quick answer**
Print the field with `woocommerce_admin_order_data_after_order_details`, check `$order->get_status()`, and save with the order object API.

## Why did the old ACF rule work, and why does it fail now?

Orders used to be a custom post type, `shop_order`, so ACF could target them with location rules such as "Post Type is equal to Order" and "Post Status is equal to Processing". WooCommerce statuses are stored with a `wc-` prefix, which is why the rule list showed them as separate post statuses.

Since WooCommerce 8.2, new stores use **High-Performance Order Storage (HPOS)**. Orders live in dedicated tables and the edit screen is a custom admin page rather than a post edit screen. ACF's location rules, built around posts, may not recognise it. Support in ACF has been changing across versions, so check ACF's current documentation for your version. Do not rely on the old rule. Check your own setting under **WooCommerce, Settings, Advanced, Features**.

## Which storage mode fits which method?

| Storage | Method |
|:--|:--|
| HPOS (new stores) | WooCommerce hooks and the order object API |
| Legacy posts | ACF location rules Post Type and Post Status still work |
| Unsure | Hooks work in both, because they use the order API |

_A field that appears only while the order is Processing or On hold_

## What is the most reliable way?

Print the field yourself with a WooCommerce action. It is portable across storage modes because it uses the order object API, `$order->get_meta()` and `$order->update_meta_data()`, rather than post functions.

```php
add_action( 'woocommerce_admin_order_data_after_order_details', function ( $order ) {
	// Statuses without the "wc-" prefix.
	$allowed = array( 'processing', 'on-hold' );

	if ( ! in_array( $order->get_status(), $allowed, true ) ) {
		return;
	}

	woocommerce_wp_text_input( array(
		'id'    => '_shipment_reference',
		'label' => __( 'Shipment reference', 'my-shop' ),
		'value' => $order->get_meta( '_shipment_reference' ),
	) );
} );

add_action( 'woocommerce_process_shop_order_meta', function ( $order_id ) {
	if ( ! current_user_can( 'edit_shop_order', $order_id ) ) {
		return;
	}

	$order = wc_get_order( $order_id );
	if ( ! $order || ! isset( $_POST['_shipment_reference'] ) ) {
		return;
	}

	$order->update_meta_data(
		'_shipment_reference',
		sanitize_text_field( wp_unslash( $_POST['_shipment_reference'] ) )
	);
	$order->save();
} );
```

Notes on the code:

- `get_status()` returns the status slug without `wc-`, such as `processing`, `on-hold`, `completed`, `cancelled`, `refunded`, `failed` or `pending`. Custom statuses use their own slug.
- The first hook runs while the order details panel is drawn and prints the input only for allowed statuses.
- The second runs when the order is saved. WooCommerce checks its security nonce before firing it, and the code adds a capability check and sanitises the input.
- A leading underscore keeps the meta key hidden from the Custom Fields box.

## How do I keep using ACF values elsewhere?

If you stored the field with ACF and want ACF functions to see it, use the same key as the field name and read it with `$order->get_meta( 'field_name' )`. In templates or emails, the order object is the safer reader than `get_field( 'name', $order_id )`, which depends on post storage. ACF stores a hidden reference key as well (the field key, prefixed with an underscore), so values written outside ACF may not show up in ACF's own interface. For simple needs such as one text or date field, skip ACF here and use the WooCommerce functions above. Keep ACF for products and posts, where it works as documented.

## What if I still use legacy post storage?

If your store uses posts for orders, the ACF route remains valid:

1. **Edit** the field group and open **Location**.
2. **Choose** **Post Type**, is equal to, **Order**.
3. **Add** an **and** rule: **Post Status**, is equal to, then pick the status, for example "Processing".
4. **Update** the group, and open an order with that status to confirm the group appears.

Remember a field group shown by status disappears when the status changes. Data you saved earlier remains in the database, but nobody sees it on the screen. If the data matters after completion, keep a read-only display for later statuses.

## Common problems

| Problem | What to do |
|:--|:--|
| Field does not appear after the status change | Save the order first; the screen shows the old state until then |
| Value does not save | Check the input name matches the key and that the user can edit orders |
| Compatibility warnings | A plugin not declaring HPOS compatibility may be the reason; do not turn on compatibility mode in production without testing |
| Custom statuses | Add their slugs to the `$allowed` array |

## How should I handle permissions and audit needs?

Fields on orders often hold information customers or accountants rely on, so think about who can edit them. The `edit_shop_order` capability check in the example restricts saving to users who can edit orders, and you can tighten it further with a custom capability. If you need a history of changes, add an order note when the value changes, using `$order->add_order_note()`, so staff can see who changed what and when. That note also appears in the order timeline, which avoids silent edits.

## Need a bigger change?

Order screens, emails and invoices that depend on custom data are easy to get subtly wrong, and a mistake touches customers. Our [WooCommerce experts](/woocommerce-experts) and [plugin development team](/wordpress-plugin-development) build and test these with HPOS in mind. For small store tweaks see how to [add text before or after prices](/woocommerce-add-text-before-after-price) and [customise the My Account menu](/how-to-add-remove-or-customize-any-link-from-my-account-menu-in-woocommerce).

- **WooCommerce experts** Order screens, emails and invoices built with HPOS in mind. [Read more](/woocommerce-experts)
- **Plugin development** Custom order fields as a plugin. [Read more](/wordpress-plugin-development)

**Need a bigger order-screen change?**
A person will scope it and quote in writing.
[Post a project](/post-project)
[Call the help desk](tel:+18043754450)

## Frequently asked questions

### Why does my ACF field group no longer show on WooCommerce orders?

Newer WooCommerce stores save orders in their own tables (High-Performance Order Storage) instead of as posts. ACF location rules that depend on post types and post status do not apply to that order screen.

### How do I know whether my store uses HPOS?

Go to WooCommerce, Settings, Advanced, Features and check the order data storage setting. New stores use HPOS by default.

### Can I keep using ACF for the data?

You can read and write ACF field values through order meta, but the order edit screen needs a WooCommerce hook to display the inputs when HPOS is active.

### Why does my ACF field group no longer show on WooCommerce orders?

Newer stores save orders in their own tables, High-Performance Order Storage, instead of as posts. ACF location rules built around post types and post status do not apply to that order screen.

### How do I know if my store uses HPOS?

Go to WooCommerce, Settings, Advanced, Features and check the order data storage setting. New stores use HPOS by default since WooCommerce 8.2.

### What status slugs do I use in code?

The slug without the wc- prefix, such as processing, on-hold, completed, cancelled, refunded, failed or pending. Custom statuses use their own slug, which you add to the allowed array.

### Can I keep ACF for this field?

You can read and write ACF values through order meta, but the order edit screen needs a WooCommerce hook to display the inputs under HPOS. For one simple field, skip ACF here and use the WooCommerce functions.

### Why use the order object API?

$order->get_meta() and update_meta_data() are portable across storage modes, whereas post functions depend on posts. In templates and emails the order object is the safer reader than get_field with an order ID.

### Why does the field disappear when the status changes?

The hook prints the input only for allowed statuses, so the field is hidden for others. Data saved earlier remains in the database; keep a read-only display for later statuses if it matters after completion.

### The value does not save. What should I check?

Check the input name matches the meta key and that you saved with a user who can edit orders. The save hook checks the edit_shop_order capability and sanitises the input.

### Why does the field not appear right after I change the status?

The screen still shows the old state until you save the order. Save first, then the page reloads with the new status.

### How can I track who changed the value?

Add an order note with add_order_note when the value changes, so staff can see who changed what and when in the order timeline. A custom capability can tighten who can edit.

### What if my store still uses legacy post storage?

The ACF route remains valid: add a location rule Post Type equal to Order and an and rule Post Status equal to the status. Update the group and open an order with that status to confirm it appears.
