PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | src/PreviewEmail/PreviewEmailWoo.php +15 -3 4.4.1 → 4.4.5 View file →
@@ -17,9 +17,9 @@
17 17 public static $recipient;
18 18
19 19 private function __construct() {}
20 20
21 - public static function email_preview_output( $order_id, $email_id, $email_address = '' ) {
21 + public static function email_preview_output( $order_id, $email_id, $email_address = '', $variant = '' ) {
22 22 $current_email = yaymail_get_email( $email_id );
23 23 $current_email = ! empty( $current_email ) && method_exists( $current_email, 'get_root_email' ) ? $current_email->get_root_email() : '';
24 24
25 25 if ( empty( $current_email ) ) {
@@ -32,11 +32,13 @@
32 32
33 33 $email_class = get_class( $current_email );
34 34
35 35 $order = wc_get_order( $order_id );
36 - $template_data = new YayMailTemplate( $email_id );
36 + $template_data = new YayMailTemplate( $email_id, '', $variant );
37 + // Enabled-ness always comes from the default design; the variant only swaps the layout.
38 + $default_template = '' === $variant ? $template_data : new YayMailTemplate( $email_id );
37 39
38 - if ( ! $template_data->is_enabled() ) {
40 + if ( ! $default_template->is_enabled() ) {
39 41 return self::render_default_preview( $current_email, $email_class, $order );
40 42 }
41 43
42 44 self::$recipient = is_email( $email_address ) ? $email_address : '';
@@ -46,8 +48,18 @@
46 48
47 49 add_filter( 'woocommerce_email_recipient_' . $current_email->id, [ __CLASS__, 'no_recipient' ] );
48 50 add_filter( 'woocommerce_new_order_email_allows_resend', '__return_true' );
49 51 add_filter( 'yaymail_is_preview_email', '__return_true' );
52 + if ( '' !== $variant ) {
53 + // Preview the variant being edited; rule-based resolution is skipped while previewing.
54 + add_filter(
55 + 'yaymail_email_get_variant',
56 + function () use ( $variant ) {
57 + return $variant;
58 + },
59 + 20
60 + );
61 + }
50 62
51 63 $core_template_ids = SupportedPlugins::get_instance()->get_template_ids_from_core();
52 64 $addon_template_ids = SupportedPlugins::get_instance()->get_all_addon_supported_template_ids();
53 65 $supported_template_ids = array_merge( $core_template_ids, $addon_template_ids );