HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/ielts-store/wp-content/plugins/automatewoo/includes/Actions/Order_Resend_Email.php
<?php
// phpcs:ignoreFile

namespace AutomateWoo;

if ( ! defined( 'ABSPATH' ) ) exit;

/**
 * @class Action_Order_Resend_Email
 * @since 2.2
 */
class Action_Order_Resend_Email extends Action {

	public $required_data_items = [ 'order' ];


	function load_admin_details() {
		$this->title = __( 'Resend Order Email', 'automatewoo' );
		$this->group = __( 'Order', 'automatewoo' );
		$this->description = __( 'Please note that email tracking is not currently supported on this action.', 'automatewoo' );
	}


	function load_fields() {

		$options = [];
		$mailer = WC()->mailer();
		$available_emails = [
			'new_order',
			'cancelled_order',
			'failed_order',
			'customer_processing_order',
			'customer_completed_order',
			'customer_on_hold_order',
			'customer_invoice',
			'customer_refunded_order',
		];
		$mails = $mailer->get_emails(); /** @var \WC_Email[] $mails */

		if ( $mails ) foreach ( $mails as $mail ) {
			if ( in_array( $mail->id, $available_emails ) ) {
				$title = $mail->get_title();

				if ( ! $mail->is_customer_email() ) {
					$title .= ' - ' . __( 'Admin', 'automatewoo' );
				}
				else {
					$title .= ' - ' . __( 'Customer', 'automatewoo' );
				}

				$options[$mail->id] = $title;
			}
		}

		$email = new Fields\Select(true);
		$email->set_name( 'email' );
		$email->set_title( __('Email', 'automatewoo') );
		$email->set_required();
		$email->set_options( $options );

		$this->add_field($email);
	}


	function run() {
		$email_type = $this->get_option( 'email' );
		$order = $this->workflow->data_layer()->get_order();

		if ( ! $email_type || ! $order ) {
			return;
		}

		do_action( 'woocommerce_before_resend_order_emails', $order );

		// Ensure gateways are loaded in case they need to insert data into the emails
		WC()->payment_gateways();
		WC()->shipping();

		// Load mailer
		$mailer = WC()->mailer();

		if ( ! $mails = $mailer->get_emails() ) {
			return;
		}

		foreach ( $mails as $mail ) {

			if ( $mail->id != $email_type ) {
				continue;
			}

			$mail->trigger( $order->get_id() );

			do_action( 'woocommerce_after_resend_order_email', $order, $email_type );

			$order->add_order_note( sprintf( __( '%s email notification sent by AutomateWoo workflow #%d', 'automatewoo' ), $mail->title, $this->workflow->get_id()  ) );
		}
	}

}