Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes
CustomMetaBox::order_meta_keys_autofill()
Compute keys to display in autofill when adding new meta key entry in custom meta box. Currently, returns empty keys, will be implemented after caching is merged.
Method of the class: CustomMetaBox{}
Hooks from the method
Return
Array
. Array of keys to display in autofill.
Usage
$CustomMetaBox = new CustomMetaBox(); $CustomMetaBox->order_meta_keys_autofill( $deprecated, $order );
- $deprecated(mixed) (required)
- Unused argument. For backwards compatibility.
- $order(\WP_Post|\WC_Order) (required)
- Order object.
CustomMetaBox::order_meta_keys_autofill() CustomMetaBox::order meta keys autofill code WC 9.7.1
public function order_meta_keys_autofill( $deprecated, $order ) { if ( ! is_a( $order, \WC_Order::class ) ) { return array(); } /** * Filters values for the meta key dropdown in the Custom Fields meta box. * * Compatibility filter for `postmeta_form_keys` filter. * * @since 6.9.0 * * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null. * @param \WC_Order $order The current post object. */ $keys = apply_filters( 'postmeta_form_keys', null, $order ); if ( null === $keys || ! is_array( $keys ) ) { /** * Compatibility filter for 'postmeta_form_limit', which filters the number of custom fields to retrieve * for the drop-down in the Custom Fields meta box. * * @since 8.8.0 * * @param int $limit Number of custom fields to retrieve. Default 30. */ $limit = apply_filters( 'postmeta_form_limit', 30 ); $keys = wc_get_container()->get( OrdersTableDataStoreMeta::class )->get_meta_keys( $limit ); } if ( $keys ) { natcasesort( $keys ); } return $keys; }