Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit ffffa8f

Browse files
committed
Display only relevant actions for manual trigger.
1 parent 6afaabe commit ffffa8f

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

includes/class-wc-subscriptions-email-notifications.php

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,42 @@ public static function should_send_notification() {
173173
}
174174

175175
/**
176-
* Adds actions to the admin edit subscriptions page, if the subscription hasn't ended and the payment method supports them.
176+
* Adds actions to the admin edit subscriptions page.
177177
*
178178
* @param array $actions An array of available actions
179179
* @return array An array of updated actions
180-
* @since 1.0.0 - Migrated from WooCommerce Subscriptions v2.0
181180
*/
182181
public static function add_notification_actions( $actions ) {
183182
global $theorder;
184183

185184
if ( wcs_is_subscription( $theorder ) ) {
186-
//TODO maybe send only for active, on hold subscriptions?
187-
$actions['wcs_customer_notification_free_trial_expiration'] = esc_html__( 'Send Free Trial Expiration notification', 'woocommerce-subscriptions' );
188-
$actions['wcs_customer_notification_subscription_expiration'] = esc_html__( 'Send Subscription Expiration notification', 'woocommerce-subscriptions' );
189-
$actions['wcs_customer_notification_manual_renewal'] = esc_html__( 'Send Manual Renewal notification', 'woocommerce-subscriptions' );
190-
$actions['wcs_customer_notification_auto_renewal'] = esc_html__( 'Send Automatic Renewal notification', 'woocommerce-subscriptions' );
185+
$subscription = $theorder;
186+
//TODO: confirm if these statuses make sense.
187+
$allowed_statuses = array(
188+
'active',
189+
'on-hold',
190+
'pending-cancellation',
191+
);
192+
193+
if ( ! in_array( $subscription->get_status(), $allowed_statuses, true ) ) {
194+
return $actions;
195+
}
196+
197+
if ( $subscription->get_date( 'trial_end' ) ) {
198+
$actions['wcs_customer_notification_free_trial_expiration'] = esc_html__( 'Send Free Trial Expiration notification', 'woocommerce-subscriptions' );
199+
}
200+
201+
if ( $subscription->get_date( 'end' ) ) {
202+
$actions['wcs_customer_notification_subscription_expiration'] = esc_html__( 'Send Subscription Expiration notification', 'woocommerce-subscriptions' );
203+
}
204+
205+
if ( $subscription->get_date( 'next_payment' ) ) {
206+
if ( $subscription->is_manual() ) {
207+
$actions['wcs_customer_notification_manual_renewal'] = esc_html__( 'Send Manual Renewal notification', 'woocommerce-subscriptions' );
208+
} else {
209+
$actions['wcs_customer_notification_auto_renewal'] = esc_html__( 'Send Automatic Renewal notification', 'woocommerce-subscriptions' );
210+
}
211+
}
191212
}
192213

193214
return $actions;

0 commit comments

Comments
 (0)