| 1 |
<?php namespace TierPricingTable\Addons\NonLoggedInUsers\Wholesale\Emails; |
| 2 |
|
| 3 |
class EmailsManager { |
| 4 |
|
| 5 |
const ACTIONS = array( |
| 6 |
'tiered_pricing_table/wholesale/application_submitted', |
| 7 |
'tiered_pricing_table/wholesale/application_approved', |
| 8 |
'tiered_pricing_table/wholesale/application_rejected', |
| 9 |
); |
| 10 |
|
| 11 |
public function __construct() { |
| 12 |
add_filter( 'woocommerce_email_classes', array( $this, 'registerEmails' ) ); |
| 13 |
|
| 14 |
// WooCommerce loads its mailer (and with it these e-mail classes) only for the actions in this |
| 15 |
// list; each action is then re-fired as "<action>_notification", which the e-mails listen to |
| 16 |
add_filter( 'woocommerce_email_actions', array( $this, 'registerActions' ) ); |
| 17 |
} |
| 18 |
|
| 19 |
public function registerActions( $actions ): array { |
| 20 |
return array_values( array_unique( array_merge( (array) $actions, self::ACTIONS ) ) ); |
| 21 |
} |
| 22 |
|
| 23 |
public function registerEmails( array $emails ): array { |
| 24 |
$emails['TPT_Wholesale_Admin_New_Application'] = new AdminNewApplicationEmail(); |
| 25 |
$emails['TPT_Wholesale_Customer_Received'] = new CustomerApplicationReceivedEmail(); |
| 26 |
$emails['TPT_Wholesale_Customer_Approved'] = new CustomerApplicationApprovedEmail(); |
| 27 |
$emails['TPT_Wholesale_Customer_Rejected'] = new CustomerApplicationRejectedEmail(); |
| 28 |
|
| 29 |
return $emails; |
| 30 |
} |
| 31 |
} |
| 32 |
|