Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes

CustomMetaBox::search_metakeys_ajaxpublicWC 1.0

WP Ajax handler to render the list of unique meta keys asynchronously.

Method of the class: CustomMetaBox{}

No Hooks.

Returns

null. Nothing (null).

Usage

$CustomMetaBox = new CustomMetaBox();
$CustomMetaBox->search_metakeys_ajax(): void;

CustomMetaBox::search_metakeys_ajax() code WC 10.3.3

public function search_metakeys_ajax(): void {
	check_ajax_referer( 'search-order-metakeys', 'security' );

	if ( ! isset( $_GET['order_id'] ) || ! current_user_can( 'edit_shop_orders' ) ) {
		wp_die( -1 );
	}

	$order_id = intval( $_GET['order_id'] );
	$order    = wc_get_order( $order_id );
	if ( ! is_a( $order, \WC_Order::class ) ) {
		wp_die( -1 );
	}

	$found_order_meta_keys = $this->order_meta_keys_autofill( null, $order );

	wp_send_json( $found_order_meta_keys );
}