@@ -18,6 +18,7 @@ public static function init() {
18
18
19
19
add_filter ( 'woocommerce_order_actions ' , array ( __CLASS__ , 'add_notification_actions ' ), 10 , 1 );
20
20
21
+ // TODO this is a bit ugly...
21
22
add_action (
22
23
'woocommerce_order_action_wcs_customer_notification_free_trial_expiration ' ,
23
24
function ( $ order ) {
@@ -78,6 +79,8 @@ function ( $order ) {
78
79
10 ,
79
80
1
80
81
);
82
+
83
+ add_filter ( 'woocommerce_subscription_settings ' , array ( __CLASS__ , 'add_settings ' ), 20 );
81
84
}
82
85
83
86
/**
@@ -178,7 +181,6 @@ public static function add_notification_actions( $actions ) {
178
181
179
182
if ( wcs_is_subscription ( $ theorder ) ) {
180
183
//TODO maybe send only for active, on hold subscriptions?
181
- //
182
184
$ actions ['wcs_customer_notification_free_trial_expiration ' ] = esc_html__ ( 'Send Free Trial Expiration notification ' , 'woocommerce-subscriptions ' );
183
185
$ actions ['wcs_customer_notification_subscription_expiration ' ] = esc_html__ ( 'Send Subscription Expiration notification ' , 'woocommerce-subscriptions ' );
184
186
$ 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 ) {
187
189
188
190
return $ actions ;
189
191
}
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
+ }
190
233
}
0 commit comments