I added an action to woocommerce_thankyou
that has a 45 second delay in it and it causes the page to hang for 45 seconds while it executes. I was wondering if there was some way hook this to an action that could fire after the woocommerce thankyou.php
page has been built. I’ve already tried adding my own do_action
at the end of the script but that didn’t work. The page still hangs for 45 seconds.
This is the action and its function…
add_action('woocommerce_thankyou', 'call_restaurant');
function call_restaurant() {
sleep(45);
require_once '/home/mywebsite/public_html/voice/Services/call.php';
$sid = "bla bla bla";
$token = "bla bla bla";
$from_number = "3055551234"; // Calls must be made from a registered Twilio number.
$to_number = "3055551234";
$message = "Hello. You have received a new order from eat three sixty five miami dot com";
$client = new Services_Twilio($sid, $token, "2010-04-01");
/*
$call = $client->account->calls->create(
$from_number,
$to_number,
'http://twimlets.com/message?Message='.urlencode($message)
);
*/
echo 'phone call has been made';
}
The reason that I’m doing this is because I am trying to place an automated phone call 45 seconds after the order is made.
Any help is greatly appreciated.
The shopping cart is here… http://www.eat365miami.com/lee-sushi/
My solution was to hook into the wordpress footer and within the function of the action that I created, I used a woocommerce conditional tag that only outputs my ajax request if I am on the “order received” page. Here is the action that I created in my themes functions.php file…
I hope that others can find this useful 🙂