2
2
/**
3
3
* Custom Emails for WooCommerce - Emails Shortcodes Class
4
4
*
5
- * @version 2.9.5
5
+ * @version 2.9.6
6
6
* @since 1.0.0
7
7
*
8
8
* @author Algoritmika Ltd
@@ -49,7 +49,7 @@ class Alg_WC_Custom_Emails_Shortcodes {
49
49
/**
50
50
* Constructor.
51
51
*
52
- * @version 2.9.5
52
+ * @version 2.9.6
53
53
* @since 1.0.0
54
54
*
55
55
* @todo (dev) not order related (e.g., customer; product)
@@ -74,6 +74,7 @@ function __construct() {
74
74
'order_cancel_url ' ,
75
75
'order_checkout_payment_url ' ,
76
76
'order_customer_note ' ,
77
+ 'order_customer_order_notes ' ,
77
78
'order_date ' ,
78
79
'order_details ' ,
79
80
'order_downloads ' ,
@@ -227,6 +228,27 @@ function user_prop( $atts, $content = '' ) {
227
228
return $ this ->return_shortcode ( $ this ->user ->get ( $ atts ['key ' ] ), $ atts );
228
229
}
229
230
231
+ /**
232
+ * order_customer_order_notes.
233
+ *
234
+ * @version 2.9.6
235
+ * @since 2.9.6
236
+ *
237
+ * @todo (dev) `comment_date`?
238
+ * @todo (dev) `comment_author`, `comment_author_email`?
239
+ * @todo (dev) customizable glue (`<br>`)?
240
+ * @todo (dev) customizable sorting?
241
+ */
242
+ function order_customer_order_notes ( $ atts , $ content = '' ) {
243
+ if ( ! $ this ->order ) {
244
+ return '' ;
245
+ }
246
+ $ notes = $ this ->order ->get_customer_order_notes ();
247
+ $ notes = wp_list_pluck ( $ notes , 'comment_content ' );
248
+ $ notes = implode ( '<br> ' , $ notes );
249
+ return $ this ->return_shortcode ( $ notes , $ atts );
250
+ }
251
+
230
252
/**
231
253
* order_checkout_payment_url.
232
254
*
@@ -813,9 +835,11 @@ function clear( $atts, $content = '' ) {
813
835
* @version 1.0.0
814
836
* @since 1.0.0
815
837
*
816
- * @todo (dev) more common atts, e.g., find/replace, strip_tags, any_func, etc.
838
+ * @todo (dev) more common atts, e.g., on_empty, find/replace, strip_tags, any_func, etc.
817
839
*/
818
840
function return_shortcode ( $ value , $ atts ) {
841
+
842
+ // Add, multiply
819
843
if ( is_numeric ( $ value ) ) {
820
844
if ( ! empty ( $ atts ['add ' ] ) ) {
821
845
$ value += $ atts ['add ' ];
@@ -824,6 +848,8 @@ function return_shortcode( $value, $atts ) {
824
848
$ value *= $ atts ['multiply ' ];
825
849
}
826
850
}
851
+
852
+ // Format
827
853
if ( isset ( $ atts ['format ' ] ) ) {
828
854
switch ( $ atts ['format ' ] ) {
829
855
case 'price ' :
@@ -833,7 +859,17 @@ function return_shortcode( $value, $atts ) {
833
859
$ value = sprintf ( $ atts ['format ' ], $ value );
834
860
}
835
861
}
836
- return ( '' !== $ value ? ( ( isset ( $ atts ['before ' ] ) ? $ atts ['before ' ] : '' ) . $ value . ( isset ( $ atts ['after ' ] ) ? $ atts ['after ' ] : '' ) ) : '' );
862
+
863
+ // Before, after
864
+ return ( '' !== $ value ?
865
+ (
866
+ ( isset ( $ atts ['before ' ] ) ? $ atts ['before ' ] : '' ) .
867
+ $ value .
868
+ ( isset ( $ atts ['after ' ] ) ? $ atts ['after ' ] : '' )
869
+ ) :
870
+ ''
871
+ );
872
+
837
873
}
838
874
839
875
}
0 commit comments