Modify the following function so that it will wait for 5 seconds after order creation before executing. use wp_schedule_single_event to make it a cron job that doesn’t block other code from running. add_action( ‘woocommerce_new_order’, ‘st_Send_invoice_for_pending_payment’, 20, 1 ); function st_Send_invoice_for_pending_payment( $order_id ) { // Get the order instance. $order = wc_get_order( $order_id ); if ( is_a( $order, ‘WC_Order’ ) && $order->get_status() == ‘pending’ ) { WC()->mailer()->emails[’WC_Email_Customer_Invoice’]->trigger($order_id); } } April 19, 2024
Modify the following function so that it will wait for 5 seconds after order creation before executing: add_action( ‘woocommerce_new_order’, ‘st_Send_invoice_for_pending_payment’, 20, 1 ); function st_Send_invoice_for_pending_payment( $order_id ) { // Get the order instance. $order = wc_get_order( $order_id ); if ( is_a( $order, ‘WC_Order’ ) && $order->get_status() == ‘pending’ ) { WC()->mailer()->emails[’WC_Email_Customer_Invoice’]->trigger($order_id); } } April 19, 2024
Modify the following code so that it only runs if the order status is pending payment: $order = wc_get_order( $order_id ); if ( is_a( $order, ‘WC_Order’ ) ) { WC()->mailer()->emails[’WC_Email_Customer_Invoice’]->trigger($order_id); } April 19, 2024