Да, всплывающие окна должны быть прямым результатом действия пользователя. Выполнение их в обратном вызове ajax не поможет. Кроме того, использование async:false
плохо - в FF, как известно, блокируется весь браузер. Подумайте о другом способе сделать проверку:
Вы можете использовать доступную ловушку фильтра woocommerce_shop_order_search_results
, расположенную в конце функции , которая позволит переопределить этот метод:
add_filter( 'woocommerce_shop_order_search_results', 'custom_shop_order_search_results_filter', 10, 3 );
function custom_shop_order_search_results_filter( $order_ids, $term, $search_fields ) {
global $wpdb;
$term = preg_replace('/[^0-9.]+/', '', $term); // <=== <=== <=== Your change
$order_ids = array();
if ( is_numeric( $term ) ) {
$order_ids[] = absint( $term );
}
if ( ! empty( $search_fields ) ) {
$order_ids = array_unique(
array_merge(
$order_ids,
$wpdb->get_col(
$wpdb->prepare(
"SELECT DISTINCT p1.post_id FROM {$wpdb->postmeta} p1 WHERE p1.meta_value LIKE %s AND p1.meta_key IN ('" . implode( "','", array_map( 'esc_sql', $search_fields ) ) . "')", // @codingStandardsIgnoreLine
'%' . $wpdb->esc_like( wc_clean( $term ) ) . '%'
)
),
$wpdb->get_col(
$wpdb->prepare(
"SELECT order_id
FROM {$wpdb->prefix}woocommerce_order_items as order_items
WHERE order_item_name LIKE %s",
'%' . $wpdb->esc_like( wc_clean( $term ) ) . '%'
)
)
)
);
}
return $order_ids
}
Код идет в файле function.php вашей активной детской темы (или активной темы). Проверено, оно должно работать.