get_created_via(); $user_id = $order->get_user_id(); if ( ! wp_next_scheduled( 'aisp_otools_check_pending_admin', [ $order_id ] ) ) { wp_schedule_single_event( time() + 10, 'aisp_otools_check_pending_admin', [ $order_id ] ); } } public function send_pending_email_admin( $order_id ) { $order = wc_get_order( $order_id ); if ( ! $order || 'pending' !== $order->get_status() ) { return; } $mailer = WC()->mailer(); $admin_email = get_option( 'admin_email' ); $custom = get_option( 'aisp_otools_admin_subject_invoice_pending', '' ); if ( ! empty( $custom ) ) { $subject = AISP_OTools_Email_Helper::replace_placeholders( $custom, $order ); } else { $subject = sprintf(// translators: #%s is the order number (e.g 1234) __( 'New pending order: #%s', 'aisp-order-tools-for-woocommerce' ), $order->get_order_number() ); $subject = AISP_OTools_Email_Helper::replace_placeholders( $subject, $order ); } $order_total = $order->get_formatted_order_total(); $body = '

' . __( 'A new order is still pending payment.', 'aisp-order-tools-for-woocommerce' ) . '

'; $body .= '

' . __( 'Order total:', 'aisp-order-tools-for-woocommerce' ) . ' ' . wp_kses_post( $order_total ) . '

'; $body .= '

'; $body .= sprintf(// translators: %2$2s is the link to view the order __( 'View order: %2$2s', 'aisp-order-tools-for-woocommerce' ), esc_url( admin_url( 'post.php?post=' . $order_id . '&action=edit' ) ), __( 'Click here to open this order in WooCommerce', 'aisp-order-tools-for-woocommerce' ) ); $body .= '

'; $body = AISP_OTools_Email_Helper::replace_placeholders( $body, $order ); $mailer->send( $admin_email, $subject, $mailer->wrap_message( $subject, $body ) ); } public function custom_admin_subject_new_order( $subject, $order ) { if ( ! $order instanceof \WC_Order ) { return $subject; } $status = $order->get_status(); $new_subject = ''; switch ( $status ) { case 'pending': $new_subject = get_option( 'aisp_otools_admin_subject_pending', __( 'New order awaiting payment', 'aisp-order-tools-for-woocommerce' ) ); break; case 'on-hold': $new_subject = get_option( 'aisp_otools_admin_subject_on_hold', __( 'New order on hold – payment to be confirmed', 'aisp-order-tools-for-woocommerce' ) ); break; case 'processing': $new_subject = get_option( 'aisp_otools_admin_subject_processing', __( 'New paid order received', 'aisp-order-tools-for-woocommerce' ) ); break; } if ( empty( $new_subject ) ) { return $subject; } return AISP_OTools_Email_Helper::replace_placeholders( $new_subject, $order ); } }