Skip to content

Commit 056d8d4

Browse files
committed
v2.9.3
1 parent df3b8ed commit 056d8d4

8 files changed

+224
-170
lines changed

changelog.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
== Changelog ==
22

3+
= 2.9.3 - 13/03/2024 =
4+
* Dev - Triggers - Extra - "Customer address changed" and "Customer address saved" triggers added.
5+
* Dev - Scheduled - Admin - Object ID validation added.
6+
37
= 2.9.2 - 01/03/2024 =
48
* Readme.txt - Changelog - Truncated (full changelog moved to the `changelog.txt` file).
59
* Readme.txt - Tags - `woo commerce` tag removed.

custom-emails-for-woocommerce.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Additional Custom Emails for WooCommerce
44
Plugin URI: https://wpfactory.com/item/custom-emails-for-woocommerce/
55
Description: Add custom emails to WooCommerce.
6-
Version: 2.9.2
6+
Version: 2.9.3
77
Author: WPFactory
88
Author URI: https://wpfactory.com
99
Text Domain: custom-emails-for-woocommerce
@@ -30,7 +30,7 @@
3030
}
3131
}
3232

33-
defined( 'ALG_WC_CUSTOM_EMAILS_VERSION' ) || define( 'ALG_WC_CUSTOM_EMAILS_VERSION', '2.9.2' );
33+
defined( 'ALG_WC_CUSTOM_EMAILS_VERSION' ) || define( 'ALG_WC_CUSTOM_EMAILS_VERSION', '2.9.3' );
3434

3535
defined( 'ALG_WC_CUSTOM_EMAILS_FILE' ) || define( 'ALG_WC_CUSTOM_EMAILS_FILE', __FILE__ );
3636

includes/class-alg-wc-custom-emails-core.php

+35-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Custom Emails for WooCommerce - Core Class
44
*
5-
* @version 2.6.0
5+
* @version 2.9.3
66
* @since 1.0.0
77
*
88
* @author Algoritmika Ltd
@@ -41,7 +41,7 @@ class Alg_WC_Custom_Emails_Core {
4141
/**
4242
* Constructor.
4343
*
44-
* @version 2.6.0
44+
* @version 2.9.3
4545
* @since 1.0.0
4646
*
4747
* @todo (feature) option to conditionally disable some standard WC emails (e.g., "order completed" email, etc.)?
@@ -63,6 +63,9 @@ function __construct() {
6363
// Templates
6464
add_filter( 'woocommerce_locate_template', array( $this, 'locate_template' ), 10, 3 );
6565

66+
// User address changed
67+
add_action( 'woocommerce_after_save_address_validation', array( $this, 'alg_wc_ce_user_address_changed' ), 10, 4 );
68+
6669
// Product published
6770
add_action( 'transition_post_status', array( $this, 'alg_wc_ce_product_published' ), 10, 3 );
6871

@@ -95,6 +98,31 @@ function debug( $message ) {
9598
}
9699
}
97100

101+
/**
102+
* alg_wc_ce_user_address_changed.
103+
*
104+
* @version 2.9.3
105+
* @since 2.9.3
106+
*
107+
* @see https://github.com/woocommerce/woocommerce/blob/8.6.1/plugins/woocommerce/includes/class-wc-form-handler.php#L200
108+
*
109+
* @todo (dev) run this only if `alg_wc_ce_user_address_changed` is in `$email->get_option( 'trigger' )` for at least one of the emails?
110+
* @todo (feature) `alg_wc_ce_user_billing_address_changed` and `alg_wc_ce_user_shipping_address_changed`
111+
* @todo (feature) show "changes" (with a shortcode?)
112+
*/
113+
function alg_wc_ce_user_address_changed( $user_id, $address_type, $address, $customer ) {
114+
115+
if ( 0 < wc_notice_count( 'error' ) ) {
116+
return;
117+
}
118+
119+
$data_changes = ( $customer ? $customer->get_changes() : false );
120+
if ( ! empty( $data_changes ) ) {
121+
do_action( 'alg_wc_ce_user_address_changed', $user_id );
122+
}
123+
124+
}
125+
98126
/**
99127
* alg_wc_ce_product_published.
100128
*
@@ -198,7 +226,7 @@ function send_email( $email, $object_id, $note = '' ) {
198226
/**
199227
* add_custom_email_trigger_actions.
200228
*
201-
* @version 2.6.0
229+
* @version 2.9.3
202230
* @since 1.0.0
203231
*
204232
* @todo (dev) [!] maybe we need to add "Subscriptions: Renewals" here (`'woocommerce_order_status_' . $slug . '_renewal'`, `'woocommerce_order_status_' . $slug . '_to_' . $_slug . '_renewal'`)?
@@ -221,6 +249,10 @@ function add_custom_email_trigger_actions( $email_actions ) {
221249
}
222250
}
223251

252+
// Users
253+
$email_actions[] = 'woocommerce_after_save_address_validation';
254+
$email_actions[] = 'alg_wc_ce_user_address_changed';
255+
224256
// Products
225257
$email_actions[] = 'alg_wc_ce_product_published';
226258
$email_actions[] = 'woocommerce_update_product';

includes/classes/class-alg-wc-custom-email.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Custom Emails for WooCommerce - Custom Email Class
44
*
5-
* @version 2.9.1
5+
* @version 2.9.3
66
* @since 1.0.0
77
*
88
* @author Algoritmika Ltd
@@ -323,7 +323,7 @@ function alg_wc_ce_get_delay_start_time( $object_id ) {
323323
/**
324324
* alg_wc_ce_send_email.
325325
*
326-
* @version 2.9.1
326+
* @version 2.9.3
327327
* @since 1.3.0
328328
*
329329
* @todo (dev) `wc_get_product( $object_id )`: better solution, e.g., use `current_filter()`?
@@ -371,7 +371,11 @@ function alg_wc_ce_send_email( $object_id, $do_force_send, $note = '' ) {
371371
if ( $object_id ) {
372372

373373
if (
374-
'woocommerce_created_customer_notification' === current_filter() ||
374+
in_array( current_filter(), array(
375+
'woocommerce_created_customer_notification',
376+
'woocommerce_after_save_address_validation_notification',
377+
'alg_wc_ce_user_address_changed_notification',
378+
) ) ||
375379
apply_filters( 'alg_wc_custom_emails_is_user_email', false, current_filter() )
376380
) {
377381

includes/settings/class-alg-wc-custom-email-settings.php

+14-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Custom Emails for WooCommerce - Email Settings Class
44
*
5-
* @version 2.9.0
5+
* @version 2.9.3
66
* @since 1.0.0
77
*
88
* @author Algoritmika Ltd
@@ -89,7 +89,7 @@ function get_default_content() {
8989
/**
9090
* get_triggers.
9191
*
92-
* @version 2.6.0
92+
* @version 2.9.3
9393
* @since 1.0.0
9494
*
9595
* @todo (dev) `alg_wc_ce_product_published_notification`: `woocommerce_new_product`?
@@ -132,16 +132,18 @@ function get_triggers() {
132132

133133
// Extra triggers
134134
$triggers['extra'] = array(
135-
'woocommerce_reset_password_notification' => __( 'Reset password notification', 'custom-emails-for-woocommerce' ),
136-
'woocommerce_order_fully_refunded_notification' => __( 'Order fully refunded notification', 'custom-emails-for-woocommerce' ),
137-
'woocommerce_order_partially_refunded_notification' => __( 'Order partially refunded notification', 'custom-emails-for-woocommerce' ),
138-
'woocommerce_new_customer_note_notification' => __( 'New customer note notification', 'custom-emails-for-woocommerce' ),
139-
'woocommerce_low_stock_notification' => __( 'Low stock notification', 'custom-emails-for-woocommerce' ),
140-
'woocommerce_no_stock_notification' => __( 'No stock notification', 'custom-emails-for-woocommerce' ),
141-
'woocommerce_product_on_backorder_notification' => __( 'Product on backorder notification', 'custom-emails-for-woocommerce' ),
142-
'alg_wc_ce_product_published_notification' => __( 'Product published', 'custom-emails-for-woocommerce' ),
143-
'woocommerce_update_product_notification' => __( 'Product updated', 'custom-emails-for-woocommerce' ),
144-
'woocommerce_created_customer_notification' => __( 'Created customer notification', 'custom-emails-for-woocommerce' ),
135+
'woocommerce_reset_password_notification' => __( 'Reset password notification', 'custom-emails-for-woocommerce' ),
136+
'woocommerce_order_fully_refunded_notification' => __( 'Order fully refunded notification', 'custom-emails-for-woocommerce' ),
137+
'woocommerce_order_partially_refunded_notification' => __( 'Order partially refunded notification', 'custom-emails-for-woocommerce' ),
138+
'woocommerce_new_customer_note_notification' => __( 'New customer note notification', 'custom-emails-for-woocommerce' ),
139+
'woocommerce_low_stock_notification' => __( 'Low stock notification', 'custom-emails-for-woocommerce' ),
140+
'woocommerce_no_stock_notification' => __( 'No stock notification', 'custom-emails-for-woocommerce' ),
141+
'woocommerce_product_on_backorder_notification' => __( 'Product on backorder notification', 'custom-emails-for-woocommerce' ),
142+
'alg_wc_ce_product_published_notification' => __( 'Product published', 'custom-emails-for-woocommerce' ),
143+
'woocommerce_update_product_notification' => __( 'Product updated', 'custom-emails-for-woocommerce' ),
144+
'woocommerce_created_customer_notification' => __( 'Created customer notification', 'custom-emails-for-woocommerce' ),
145+
'woocommerce_after_save_address_validation_notification' => __( 'Customer address saved', 'custom-emails-for-woocommerce' ),
146+
'alg_wc_ce_user_address_changed_notification' => __( 'Customer address changed', 'custom-emails-for-woocommerce' ),
145147
);
146148

147149
// WooCommerce Subscriptions

includes/settings/class-alg-wc-custom-emails-settings-scheduled.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Custom Emails for WooCommerce - Scheduled Section Settings
44
*
5-
* @version 2.7.0
5+
* @version 2.9.3
66
* @since 1.3.0
77
*
88
* @author Algoritmika Ltd
@@ -109,7 +109,7 @@ function get_formatted_local_time( $timestamp ) {
109109
/**
110110
* get_delayed_emails_info.
111111
*
112-
* @version 2.7.0
112+
* @version 2.9.3
113113
* @since 1.3.0
114114
*
115115
* @todo (dev) better solution instead of `_get_cron_array()`?
@@ -133,8 +133,8 @@ function get_delayed_emails_info() {
133133
$result[] = sprintf( '<td>%s</td><td>%s</td><td>%s</td><td>%s</td>',
134134
$this->get_email_title_from_class( $class ),
135135
$this->get_formatted_local_time( $timestamp ),
136-
$object_id,
137-
$this->get_unschedule_button_html_wp_cron( $class, $object_id, $timestamp )
136+
( is_scalar( $object_id ) ? $object_id : '' ),
137+
( is_scalar( $object_id ) ? $this->get_unschedule_button_html_wp_cron( $class, $object_id, $timestamp ) : '' )
138138
);
139139
}
140140
}
@@ -157,7 +157,7 @@ function get_delayed_emails_info() {
157157
$result[] = sprintf( '<td>%s</td><td>%s</td><td>%s</td><td>%s</td>',
158158
$this->get_email_title_from_class( $class ),
159159
$this->get_formatted_local_time( $scheduled_action->get_schedule()->get_date()->getTimestamp() ),
160-
$object_id,
160+
( is_scalar( $object_id ) ? $object_id : '' ),
161161
$this->get_unschedule_button_html_as( $scheduled_action_id )
162162
);
163163
}

0 commit comments

Comments
 (0)