finalizing subscription moduile, ready to test
This commit is contained in:
@@ -107,32 +107,6 @@ class TemplateProvider {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WooCommerce email template content
|
||||
*
|
||||
* @param string $email_id WooCommerce email ID
|
||||
* @return array|null
|
||||
*/
|
||||
private static function get_wc_email_template($email_id) {
|
||||
if (!function_exists('WC')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$mailer = WC()->mailer();
|
||||
$emails = $mailer->get_emails();
|
||||
|
||||
if (isset($emails[$email_id])) {
|
||||
$email = $emails[$email_id];
|
||||
return [
|
||||
'subject' => $email->get_subject(),
|
||||
'heading' => $email->get_heading(),
|
||||
'enabled' => $email->is_enabled(),
|
||||
];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default templates
|
||||
*
|
||||
@@ -264,6 +238,11 @@ class TemplateProvider {
|
||||
return self::get_customer_variables();
|
||||
}
|
||||
|
||||
// Subscription events
|
||||
if (strpos($event_id, 'subscription_') === 0) {
|
||||
return self::get_subscription_variables();
|
||||
}
|
||||
|
||||
// All other events are order-related
|
||||
return self::get_order_variables();
|
||||
}
|
||||
@@ -330,6 +309,29 @@ class TemplateProvider {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available subscription variables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_subscription_variables() {
|
||||
return [
|
||||
'subscription_id' => __('Subscription ID', 'woonoow'),
|
||||
'subscription_status' => __('Subscription Status', 'woonoow'),
|
||||
'product_name' => __('Product Name', 'woonoow'),
|
||||
'billing_period' => __('Billing Period (e.g., Monthly)', 'woonoow'),
|
||||
'recurring_amount' => __('Recurring Amount', 'woonoow'),
|
||||
'next_payment_date' => __('Next Payment Date', 'woonoow'),
|
||||
'end_date' => __('Subscription End Date', 'woonoow'),
|
||||
'cancel_reason' => __('Cancellation Reason', 'woonoow'),
|
||||
'customer_name' => __('Customer Name', 'woonoow'),
|
||||
'customer_email' => __('Customer Email', 'woonoow'),
|
||||
'store_name' => __('Store Name', 'woonoow'),
|
||||
'store_url' => __('Store URL', 'woonoow'),
|
||||
'my_account_url' => __('My Account URL', 'woonoow'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace variables in template
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user