'shop_coupon', 'post_status' => 'publish', ); $query = new WP_Query( $query_args ); foreach ( $query->posts as $post ) { if ( ! empty( $post ) ) { $code = \wc_format_coupon_code( $post->post_title ); $coupons[ $code ] = array( 'label' => $post->post_title, 'id' => $code, ); } } return $coupons; } public static function get_field_value_type() { return static::TYPE_STRING; } public static function get_id() { return 'coupon_used'; } public static function get_supported_filters() { return array( 'autocomplete' ); } public static function is_ajax_field() { return true; } public static function get_validators() { return array( 'required' ); } }