You've already forked wc-licensed-product
Refactor email to use WooCommerce transactional email system
- Remove legacy email template files - Use WooCommerce's email-header.php and email-footer.php templates - Render email content inline for consistent WooCommerce styling - Remove template location filter from LicenseEmailController Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* License Expiration Warning Email (HTML)
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/emails/license-expiration.php.
|
||||
*
|
||||
* @package Jeremias\WcLicensedProduct\Templates\Emails
|
||||
* @version 0.0.8
|
||||
*
|
||||
* @var \Jeremias\WcLicensedProduct\License\License $license
|
||||
* @var int $days_remaining
|
||||
* @var string $product_name
|
||||
* @var string $expiration_date
|
||||
* @var string $email_heading
|
||||
* @var string $additional_content
|
||||
* @var bool $sent_to_admin
|
||||
* @var bool $plain_text
|
||||
* @var \Jeremias\WcLicensedProduct\Email\LicenseExpirationEmail $email
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/*
|
||||
* @hooked WC_Emails::email_header() Output the email header
|
||||
*/
|
||||
do_action('woocommerce_email_header', $email_heading, $email);
|
||||
|
||||
$customer = get_userdata($license->getCustomerId());
|
||||
$customer_name = $customer ? $customer->display_name : __('Customer', 'wc-licensed-product');
|
||||
$account_url = wc_get_account_endpoint_url('licenses');
|
||||
?>
|
||||
|
||||
<p><?php printf(esc_html__('Hello %s,', 'wc-licensed-product'), esc_html($customer_name)); ?></p>
|
||||
|
||||
<?php if ($days_remaining === 1) : ?>
|
||||
<p style="color: #dc3545; font-weight: 600;">
|
||||
<?php printf(
|
||||
esc_html__('Your license for %s will expire tomorrow (%s).', 'wc-licensed-product'),
|
||||
esc_html($product_name),
|
||||
esc_html($expiration_date)
|
||||
); ?>
|
||||
</p>
|
||||
<?php else : ?>
|
||||
<p style="color: #856404; font-weight: 600;">
|
||||
<?php printf(
|
||||
esc_html__('Your license for %1$s will expire in %2$d days (%3$s).', 'wc-licensed-product'),
|
||||
esc_html($product_name),
|
||||
$days_remaining,
|
||||
esc_html($expiration_date)
|
||||
); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2><?php esc_html_e('License Details', 'wc-licensed-product'); ?></h2>
|
||||
|
||||
<div style="margin-bottom: 40px;">
|
||||
<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="td" scope="row" style="text-align:left;"><?php esc_html_e('Product:', 'wc-licensed-product'); ?></th>
|
||||
<td class="td" style="text-align:left;"><?php echo esc_html($product_name); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="td" scope="row" style="text-align:left;"><?php esc_html_e('License Key:', 'wc-licensed-product'); ?></th>
|
||||
<td class="td" style="text-align:left;">
|
||||
<code style="background: #f5f5f5; padding: 3px 8px; border-radius: 3px; font-family: monospace;">
|
||||
<?php echo esc_html($license->getLicenseKey()); ?>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="td" scope="row" style="text-align:left;"><?php esc_html_e('Domain:', 'wc-licensed-product'); ?></th>
|
||||
<td class="td" style="text-align:left;"><?php echo esc_html($license->getDomain()); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="td" scope="row" style="text-align:left;"><?php esc_html_e('Expires:', 'wc-licensed-product'); ?></th>
|
||||
<td class="td" style="text-align:left; color: #dc3545; font-weight: 600;"><?php echo esc_html($expiration_date); ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php if ($additional_content) : ?>
|
||||
<p><?php echo wp_kses_post($additional_content); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p style="margin-top: 25px;">
|
||||
<a href="<?php echo esc_url($account_url); ?>" style="display: inline-block; background: #7f54b3; color: #fff; padding: 12px 24px; text-decoration: none; border-radius: 4px; font-weight: 600;">
|
||||
<?php esc_html_e('View My Licenses', 'wc-licensed-product'); ?>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
/*
|
||||
* @hooked WC_Emails::email_footer() Output the email footer
|
||||
*/
|
||||
do_action('woocommerce_email_footer', $email);
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* License Expiration Warning Email (Plain Text)
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/license-expiration.php.
|
||||
*
|
||||
* @package Jeremias\WcLicensedProduct\Templates\Emails
|
||||
* @version 0.0.8
|
||||
*
|
||||
* @var \Jeremias\WcLicensedProduct\License\License $license
|
||||
* @var int $days_remaining
|
||||
* @var string $product_name
|
||||
* @var string $expiration_date
|
||||
* @var string $email_heading
|
||||
* @var string $additional_content
|
||||
* @var bool $sent_to_admin
|
||||
* @var bool $plain_text
|
||||
* @var \Jeremias\WcLicensedProduct\Email\LicenseExpirationEmail $email
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n";
|
||||
echo esc_html(wp_strip_all_tags($email_heading));
|
||||
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
|
||||
|
||||
$customer = get_userdata($license->getCustomerId());
|
||||
$customer_name = $customer ? $customer->display_name : __('Customer', 'wc-licensed-product');
|
||||
|
||||
echo sprintf(esc_html__('Hello %s,', 'wc-licensed-product'), esc_html($customer_name)) . "\n\n";
|
||||
|
||||
if ($days_remaining === 1) {
|
||||
echo sprintf(
|
||||
esc_html__('Your license for %s will expire tomorrow (%s).', 'wc-licensed-product'),
|
||||
esc_html($product_name),
|
||||
esc_html($expiration_date)
|
||||
) . "\n\n";
|
||||
} else {
|
||||
echo sprintf(
|
||||
esc_html__('Your license for %1$s will expire in %2$d days (%3$s).', 'wc-licensed-product'),
|
||||
esc_html($product_name),
|
||||
$days_remaining,
|
||||
esc_html($expiration_date)
|
||||
) . "\n\n";
|
||||
}
|
||||
|
||||
echo "----------\n";
|
||||
echo esc_html__('License Details', 'wc-licensed-product') . "\n";
|
||||
echo "----------\n\n";
|
||||
|
||||
echo esc_html__('Product:', 'wc-licensed-product') . ' ' . esc_html($product_name) . "\n";
|
||||
echo esc_html__('License Key:', 'wc-licensed-product') . ' ' . esc_html($license->getLicenseKey()) . "\n";
|
||||
echo esc_html__('Domain:', 'wc-licensed-product') . ' ' . esc_html($license->getDomain()) . "\n";
|
||||
echo esc_html__('Expires:', 'wc-licensed-product') . ' ' . esc_html($expiration_date) . "\n\n";
|
||||
|
||||
if ($additional_content) {
|
||||
echo "----------\n\n";
|
||||
echo esc_html(wp_strip_all_tags(wptexturize($additional_content)));
|
||||
echo "\n\n";
|
||||
}
|
||||
|
||||
echo esc_html__('View My Licenses', 'wc-licensed-product') . ': ' . esc_url(wc_get_account_endpoint_url('licenses')) . "\n\n";
|
||||
|
||||
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n";
|
||||
Reference in New Issue
Block a user