You've already forked wc-licensed-product
- Remove Current Version field from product license settings - Derive current version from latest product version in database - Refactor email system to use WooCommerce email notification classes - Add LicenseExpirationEmail WC_Email class for expiration warnings - Add customizable email templates (HTML and plain text) - Update settings to link to WooCommerce email configuration - Update translations for new email-related strings Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
98 lines
3.8 KiB
PHP
98 lines
3.8 KiB
PHP
<?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);
|