add_action( 'wp_ajax_my_action', 'truemisha_my_action' );
add_action( 'wp_ajax_nopriv_my_action', 'truemisha_my_action' );
function truemisha_my_action() {
// Здесь вы можете выполнить любой код PHP для получения данных, которые должны быть возвращены пользователю через Ajax
$data = array(
'result' => 'success',
'message' => 'Данные успешно получены через Ajax',
'recently_viewed' => truemisha_get_recently_viewed_products()
);
wp_send_json_success( $data );
wp_die();
}
SELECT r.id
,r.type
,r.name
,rm.text
,rmf.file
FROM rooms r
INNER JOIN (
SELECT room_id, MAX(id) AS max_id
FROM room_messages
GROUP BY room_id
) rm_max ON r.id = rm_max.room_id
INNER JOIN room_messages rm
ON r.id = rm.room_id AND rm_max.max_id = rm.id
LEFT JOIN room_message_files rmf
ON rm.id = rmf.room_message_id
WHERE EXISTS (
SELECT 1
FROM room_participants rp
WHERE rp."participantType" = 'USER'
AND rp.participant_id = 1
AND rp.room_id = r.id
)
ORDER BY rm.room_id;
if ( isset ( $_POST['id'] ) )
{
$ids = implode( ',', $_POST['id'] );
$query = ("
INSERT INTO
`order_archive` (`id`, `user_id`, `articul_id`, `barcode`, `quantity`)
SELECT
`id`, `user_id`, `articul_id`, barcode`, `quantity`
FROM
`order`
WHERE
`id` IN ($ids);
DELETE FROM `order` WHERE `id` IN ($ids)");
if(mysqli_multi_query($db, $query)) {
echo 'Customer removed: ' .$ids;
} else {
echo "Error querying database: " . mysqli_error($db);
}
}