I'm using woo rest api with https://www.cloudways.com/blog/custom-dashboard-using-woocommerce-php-rest-api/ and is all good, but now i need to start triggering events like for example when there is a new order.
I've been searching for days and how to do this but can't find any info, I came across webhooks and a script to listen to the call. its an example of sending an email when the event is triggered,
I need to understand it, for instance when I get the call, how can I do a js function like an alert on the page of event as an example. here is the code.
<?php
//echo date("l jS \of F Y h:i:s A");
$msg = "woo order \n";
if($_SERVER['REQUEST_METHOD']=="POST")
{
$data = file_get_contents('php://input');
$msg .= strval($data);
}
// send email
mail("yourmail@mail.com","woo order",strval($msg));
//echo date("l jS \of F Y h:i:s A");