| 1 |
<?php |
| 2 |
namespace Emailkit\Admin\Emails; |
| 3 |
|
| 4 |
defined( "ABSPATH") || exit; |
| 5 |
|
| 6 |
class EmailLists { |
| 7 |
const NEW_ORDER = "New Order"; |
| 8 |
const CANCELLED_ORDER = "Cancelled order"; |
| 9 |
const FAILED_ORDER = "Failed Order"; |
| 10 |
const ORDER_ON_HOLD = "Order On Hold"; |
| 11 |
const PROCESSING_ORDER = "Processing Order"; |
| 12 |
const COMPLETED_ORDER = "Completed Order"; |
| 13 |
const REFUNDED_ORDER = "Refunded Order"; |
| 14 |
const LOW_STOCK = "Low Stock"; |
| 15 |
const NO_STOCK = "No Stock"; |
| 16 |
const BACK_ORDER = "Back Order"; |
| 17 |
const CUSTOMER_INVOICE_OR_ORDER_DETAILS = "Customer Invoice"; |
| 18 |
// const ORDER_DETAILS = "Order Details"; |
| 19 |
const CUSTOMER_NOTE = "Customer Note"; |
| 20 |
const RESET_PASSWORD = "Reset Password"; |
| 21 |
const NEW_ACCOUNT = "New Account"; |
| 22 |
const WP_NEW_REGISTER = "New Register"; |
| 23 |
const WP_RESET_PASSWORD = "Reset Account"; |
| 24 |
const PARTIAL_REFUND = "Partial Refund"; |
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* Get woocommerce template names |
| 29 |
* @return array |
| 30 |
*/ |
| 31 |
public static function woocommerce_email() : array { |
| 32 |
return [ |
| 33 |
'Select Template' => esc_html__('Select Template', 'emailkit'), |
| 34 |
self::NEW_ORDER => esc_html__('New Order', 'emailkit'), |
| 35 |
self::CANCELLED_ORDER => esc_html__('Cancelled order', 'emailkit'), |
| 36 |
self::FAILED_ORDER => esc_html__('Failed Order', 'emailkit'), |
| 37 |
self::ORDER_ON_HOLD => esc_html__('Order On Hold', 'emailkit'), |
| 38 |
self::PROCESSING_ORDER => esc_html__('Processing Order', 'emailkit'), |
| 39 |
self::COMPLETED_ORDER => esc_html__('Completed Order', 'emailkit'), |
| 40 |
//self::LOW_STOCK => esc_html__('Low Stock', 'emailkit'), |
| 41 |
// self::NO_STOCK => esc_html__('No Stock', 'emailkit'), |
| 42 |
// self::BACK_ORDER => esc_html__('Back Order', 'emailkit'), |
| 43 |
self::REFUNDED_ORDER => esc_html__('Refunded Order', 'emailkit'), |
| 44 |
//self::PARTIAL_REFUND => esc_html__('Partial Refund', 'emailkit'), |
| 45 |
self::CUSTOMER_INVOICE_OR_ORDER_DETAILS => esc_html__('Customer Invoice ', 'emailkit'), |
| 46 |
self::CUSTOMER_NOTE => esc_html__('Customer Note', 'emailkit'), |
| 47 |
self::NEW_ACCOUNT => esc_html__('New Account', 'emailkit'), |
| 48 |
self::RESET_PASSWORD => esc_html__('Reset Password', 'emailkit'), |
| 49 |
]; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Get wordpress template names |
| 54 |
* @return array |
| 55 |
*/ |
| 56 |
public static function wordpress_email() : array { |
| 57 |
return [ |
| 58 |
'Select Template' => esc_html__( 'Select Template', 'emailkit' ), |
| 59 |
self::WP_NEW_REGISTER => esc_html__( 'New Register', 'emailkit' ), |
| 60 |
self::WP_RESET_PASSWORD => esc_html__( 'Reset Account', 'emailkit' ), |
| 61 |
]; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
/** |
| 66 |
* Get saved templates from database |
| 67 |
* @return array |
| 68 |
*/ |
| 69 |
public static function saved_templates() : array { |
| 70 |
|
| 71 |
$emailkit_saved_templates = []; |
| 72 |
|
| 73 |
$templates = get_posts([ |
| 74 |
'post_type' => 'emailkit-template', |
| 75 |
'numberposts' => -1, |
| 76 |
]); |
| 77 |
|
| 78 |
|
| 79 |
foreach ( $templates as $template ) { |
| 80 |
|
| 81 |
setup_postdata( $template ); |
| 82 |
|
| 83 |
$template_id = get_post_meta( $template->ID, 'emailkit_template_id', true ); //get the id of main template to fetch types and etc |
| 84 |
|
| 85 |
$emailkit_saved_templates[] = array( |
| 86 |
'title' => $template->post_title, |
| 87 |
'id' => $template->ID, |
| 88 |
'template_id' => $template_id, |
| 89 |
'email_type' => get_post_meta( $template_id, 'emailkit_email_type', true ), |
| 90 |
'template_type' => get_post_meta( $template_id, 'emailkit_template_type', true ), |
| 91 |
'template_status' => get_post_meta( $template_id, 'emailkit_template_status', true ), |
| 92 |
); |
| 93 |
|
| 94 |
} |
| 95 |
|
| 96 |
wp_reset_postdata(); |
| 97 |
|
| 98 |
|
| 99 |
return $emailkit_saved_templates; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
} |