Ecommerce Shopify WordPress Discussion

`as_schedule_single_action` delay not working

I'd like to send an email to the customers when their order gets cancelled, but I would like to wait for 2 hours before I do that because I have to make sure that certain conditions are false within that 2 hour period. Sending email works, but it happens immediately, as soon as the order gets cancelled (from the admin dashboard) instead of waiting for 2 hours. What am I missing? // Ignore the code inside this function. I intentionally removed the logic function check_and_send_cancelled_notification($params) { $order_id = $params[0]; $new_status = $params[1]; $old_status = $params[2]; return $new_status; } function send_cancelled_email_schedule($order_id, $old_status, $new_status) { as_schedule_single_action( time() + 7200, 'send_cancelled_email', [ $order_id, $new_status, $old_status ] ); } add_action('woocommerce_order_status_changed', function($order_id, $old_status, $new_status) { send_cancelled_email_schedule($order_id, $old_status, $new_status); }, 10, 4);```
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.