1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
<?php
/**
* Order Delivery Date Pro for WooCommerce
*
*
* Handles email sending
*
* @author Tyche Softwares
* @package Order-Delivery-Date-Pro-for-WooCommerce/Class-ORDDD-Email-Manager
* @since 5.7
*/
/**
* ORDDD_Email_Manager Class
*
* @class ORDDD_Email_Manager
*/
class ORDDD_Email_Manager {
/**
* Constructor sets up hooks to add the
* email actions to WooCommerce emails.
*
* @since 5.7
*/
public function __construct() {
add_filter( 'woocommerce_email_classes', array( &$this, 'bkap_init_emails' ) );
// Email Actions
$email_actions = array(
'orddd_admin_update_date',
);
foreach ( $email_actions as $action ) {
add_action( $action, array( 'WC_Emails', 'send_transactional_email' ), 10, 10 );
}
add_filter( 'woocommerce_template_directory', array( $this, 'bkap_template_directory' ), 10, 2 );
}
/**
* Adds the Email class file to ensure the emails
* from the plugin are fired based on the settings.
*
* @param array $emails - List of Emails already setup by WooCommerce
* @return array $emails - List of Emails with the ones from the plugin included.
*
* @hook woocommerce_email_classes
* @since 5.7
*/
public function bkap_init_emails( $emails ) {
if ( ! isset( $emails[ 'ORDDD_Email_Update_Date' ] ) ) {
$emails[ 'ORDDD_Email_Update_Date' ] = include( 'emails/class-orddd-email-update-date.php' );
}
return $emails;
}
/**
* Returns the directory name in which the template file is present.
*
* @param string $directory - Directory Name in which the template is present.
* @param string $template - Email Template File Name
* @return string $directory - Directory Name in which the template is present. Modified when the template is for our plugin.
*
* @hook woocommerce_template_directory
* @since 5.7
*/
public function bkap_template_directory( $directory, $template ) {
if ( false !== strpos( $template, 'order-' ) ) {
return 'order-delivery-date';
}
return $directory;
}
/**
* Adds a hook to fire the delivery date/time edit email notice.
*
* @param integer $order_id - Order ID for which the Delivery Date/Time is edited.
* @param string $updated_by - States by whom are the details being updated. Valid Values: admin|customer
*
* @since 6.8
*/
public static function orddd_send_email_on_update( $order_id, $updated_by ) {
new WC_Emails();
do_action( 'orddd_admin_update_date_notification', $order_id, $updated_by );
}
}// end of class
new ORDDD_Email_Manager();
?>