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

Commit ade0f50

Browse files
committed
Added settings UI.
1 parent 5a2dc00 commit ade0f50

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

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

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public static function init() {
1818

1919
add_filter( 'woocommerce_order_actions', array( __CLASS__, 'add_notification_actions' ), 10, 1 );
2020

21+
// TODO this is a bit ugly...
2122
add_action(
2223
'woocommerce_order_action_wcs_customer_notification_free_trial_expiration',
2324
function ( $order ) {
@@ -78,6 +79,8 @@ function ( $order ) {
7879
10,
7980
1
8081
);
82+
83+
add_filter( 'woocommerce_subscription_settings', array( __CLASS__, 'add_settings' ), 20 );
8184
}
8285

8386
/**
@@ -178,7 +181,6 @@ public static function add_notification_actions( $actions ) {
178181

179182
if ( wcs_is_subscription( $theorder ) ) {
180183
//TODO maybe send only for active, on hold subscriptions?
181-
//
182184
$actions['wcs_customer_notification_free_trial_expiration'] = esc_html__( 'Send Free Trial Expiration notification', 'woocommerce-subscriptions' );
183185
$actions['wcs_customer_notification_subscription_expiration'] = esc_html__( 'Send Subscription Expiration notification', 'woocommerce-subscriptions' );
184186
$actions['wcs_customer_notification_manual_renewal'] = esc_html__( 'Send Manual Renewal notification', 'woocommerce-subscriptions' );
@@ -187,4 +189,45 @@ public static function add_notification_actions( $actions ) {
187189

188190
return $actions;
189191
}
192+
193+
/**
194+
* Adds the subscription notification setting.
195+
*
196+
* @since 8.0.0
197+
*
198+
* @param array $settings Subscriptions settings.
199+
* @return array Subscriptions settings.
200+
*/
201+
public static function add_settings( $settings ) {
202+
$notification_settings = array(
203+
array(
204+
'name' => __( 'Customer Notifications', 'woocommerce-subscriptions' ),
205+
'type' => 'title',
206+
'id' => WC_Subscriptions_Admin::$option_prefix . '_customer_notifications',
207+
/* translators: Link to WC Settings > Email. */
208+
'desc' => sprintf( __( 'To enable and disable notification, visit the <a href="%s">Email settings</a>.', 'woocommerce-subscriptions' ), admin_url( 'admin.php?page=wc-settings&tab=email' ) ),
209+
),
210+
array(
211+
'name' => __( 'Hour Offset', 'woocommerce-subscriptions' ),
212+
'desc' => __( 'How many hours in before the event should the notification be sent.', 'woocommerce-subscriptions' ),
213+
'tip' => '',
214+
'id' => WC_Subscriptions_Admin::$option_prefix . '_customer_notifications_offset',
215+
'desc_tip' => true,
216+
'type' => 'relative_date_selector',
217+
'placeholder' => __( 'N/A', 'woocommerce-subscriptions' ),
218+
'default' => array(
219+
'number' => '3',
220+
'unit' => 'days',
221+
),
222+
'autoload' => false,
223+
),
224+
array(
225+
'type' => 'sectionend',
226+
'id' => WC_Subscriptions_Admin::$option_prefix . '_customer_notifications',
227+
),
228+
);
229+
230+
WC_Subscriptions_Admin::insert_setting_after( $settings, WC_Subscriptions_Admin::$option_prefix . '_miscellaneous', $notification_settings, 'multiple_settings', 'sectionend' );
231+
return $settings;
232+
}
190233
}

0 commit comments

Comments
 (0)