diff --git a/includes/Core/Notifications/EmailRenderer.php b/includes/Core/Notifications/EmailRenderer.php index bc16478..ac4c7e0 100644 --- a/includes/Core/Notifications/EmailRenderer.php +++ b/includes/Core/Notifications/EmailRenderer.php @@ -250,6 +250,19 @@ class EmailRenderer { // Customer variables if ($data instanceof \WC_Customer) { + // Generate password reset URL for new customers + $set_password_url = ''; + $user = get_user_by('id', $data->get_id()); + if ($user) { + $reset_key = get_password_reset_key($user); + if (!is_wp_error($reset_key)) { + $set_password_url = network_site_url( + "wp-login.php?action=rp&key={$reset_key}&login=" . rawurlencode($user->user_login), + 'login' + ); + } + } + $variables = array_merge($variables, [ 'customer_id' => $data->get_id(), 'customer_name' => $data->get_display_name(), @@ -257,6 +270,9 @@ class EmailRenderer { 'customer_last_name' => $data->get_last_name(), 'customer_email' => $data->get_email(), 'customer_username' => $data->get_username(), + 'set_password_url' => $set_password_url, + 'my_account_url' => get_permalink(wc_get_page_id('myaccount')), + 'shop_url' => get_permalink(wc_get_page_id('shop')), ]); } @@ -337,10 +353,49 @@ class EmailRenderer { // Get email customization settings for colors $email_settings = get_option('woonoow_email_settings', []); + $primary_color = $email_settings['primary_color'] ?? '#7f54b3'; + $secondary_color = $email_settings['secondary_color'] ?? '#7f54b3'; + $button_text_color = $email_settings['button_text_color'] ?? '#ffffff'; $hero_gradient_start = $email_settings['hero_gradient_start'] ?? '#667eea'; $hero_gradient_end = $email_settings['hero_gradient_end'] ?? '#764ba2'; $hero_text_color = $email_settings['hero_text_color'] ?? '#ffffff'; + // Parse button shortcodes with FULL INLINE STYLES for Gmail compatibility + // Format: [button url="..." style="solid|outline"]Text[/button] + $content = preg_replace_callback( + '/\[button\s+url=["\']([^"\']+)["\'](?:\s+style=["\']?(solid|outline)["\']?)?\]([^\[]+)\[\/button\]/', + function($matches) use ($primary_color, $secondary_color, $button_text_color) { + $url = $matches[1]; + $style = $matches[2] ?? 'solid'; + $text = trim($matches[3]); + + if ($style === 'outline') { + // Outline button - transparent background with border + $button_style = sprintf( + 'display: inline-block; background-color: transparent; color: %s; padding: 14px 28px; border: 2px solid %s; border-radius: 6px; text-decoration: none; font-weight: 600; font-family: "Inter", Arial, sans-serif; font-size: 16px; text-align: center; mso-padding-alt: 0;', + esc_attr($secondary_color), + esc_attr($secondary_color) + ); + } else { + // Solid button - full background color + $button_style = sprintf( + 'display: inline-block; background-color: %s; color: %s; padding: 14px 28px; border: none; border-radius: 6px; text-decoration: none; font-weight: 600; font-family: "Inter", Arial, sans-serif; font-size: 16px; text-align: center; mso-padding-alt: 0;', + esc_attr($primary_color), + esc_attr($button_text_color) + ); + } + + // Use table-based button for better email client compatibility + return sprintf( + '
%s
', + esc_url($url), + $button_style, + esc_html($text) + ); + }, + $content + ); + $class = 'card'; $style = 'width: 100%; background-color: #ffffff; border-radius: 8px;'; $content_style = 'padding: 32px 40px;'; diff --git a/includes/Email/DefaultTemplates.php b/includes/Email/DefaultTemplates.php index 1a6fd20..16b38ef 100644 --- a/includes/Email/DefaultTemplates.php +++ b/includes/Email/DefaultTemplates.php @@ -196,13 +196,16 @@ Your account is ready. Here\'s what you can do now: ✓ Easy returns and refunds [/card] -[button url="{my_account_url}"]Access Your Account[/button] -[button url="{shop_url}"]Start Shopping[/button] +[card type="warning"] +**Important:** Please set your password to access your account: -[card type="info"] -💡 **Tip:** Check your account settings to receive personalized recommendations based on your interests. +[button url="{set_password_url}" style="solid"]Set Your Password[/button] + +This link will expire in 24 hours. Once set, you can log in anytime. [/card] +[button url="{shop_url}" style="outline"]Start Shopping[/button] + [card type="basic"] Got questions? Our customer service team is ready to help: {support_email} [/card]';