<?php

/**
 * Customer Card Expiring email
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-card-expiring.php.
 *
 * @package ArraySubs\Features\Emails\templates
 * @version 1.0.0
 *
 * @var string $email_heading Email heading.
 * @var \WP_Post $subscription Subscription post object.
 * @var int $subscription_id Subscription ID.
 * @var \WC_Product $product Product object.
 * @var \WP_User $customer Customer object.
 * @var string $card_last4 Card last 4 digits.
 * @var string $card_expiry Card expiry date.
 * @var string $update_payment_url URL to update payment method.
 * @var string $additional_content Additional content.
 * @var bool $sent_to_admin Is sent to admin.
 * @var bool $plain_text Is plain text.
 * @var \WC_Email $email Email object.
 */

defined('ABSPATH') || exit;

/*
 * @hooked WC_Emails::email_header() Output the email header
 */
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WooCommerce core hook
do_action('woocommerce_email_header', $arraysubs_email_heading, $arraysubs_email);
?>

<p>
<?php
    printf(
        /* translators: %s: Customer first name */
        esc_html__('Hi %s,', 'arraysubs'),
        esc_html($arraysubs_customer['first_name'])
    );
    ?>
    </p>

<p>
<?php
    printf(
        /* translators: %1$s: Card last 4 digits, %2$s: Card expiry date */
        esc_html__('The payment card ending in %1$s that is used for your subscription is expiring on %2$s.', 'arraysubs'),
        '<strong>' . esc_html($arraysubs_card_last4) . '</strong>',
        '<strong>' . esc_html($arraysubs_card_expiry) . '</strong>'
    );
    ?>
    </p>

<p><?php esc_html_e('To ensure uninterrupted service, please update your payment method before the expiration date.', 'arraysubs'); ?></p>

<h2><?php esc_html_e('Subscription Details', 'arraysubs'); ?></h2>

<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('Subscription ID', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left;">
                #<?php echo esc_html($arraysubs_subscription_id); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align:left;">
                <?php esc_html_e('Product', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left;">
                <?php echo esc_html($arraysubs_product ? $arraysubs_product->get_name() : __('N/A', 'arraysubs')); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align:left;">
                <?php esc_html_e('Card Ending In', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left;">
                **** **** **** <?php echo esc_html($arraysubs_card_last4); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align:left;">
                <?php esc_html_e('Card Expires', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left; color: #dc3232;">
                <?php echo esc_html($arraysubs_card_expiry); ?>
            </td>
        </tr>
    </tbody>
</table>

<p style="margin-top: 20px; text-align: center;">
    <a href="<?php echo esc_url($arraysubs_update_payment_url); ?>" class="button" style="display: inline-block; padding: 12px 24px; background-color: #dc3232; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: bold;">
        <?php esc_html_e('Update Payment Method Now', 'arraysubs'); ?>
    </a>
</p>

<p style="color: #666666; font-size: 13px;">
    <?php esc_html_e('If you do not update your payment method, your next renewal payment may fail and your subscription may be put on hold.', 'arraysubs'); ?>
</p>

<?php
/**
 * Show user-defined additional content - this is set in each email's settings.
 */
if ($arraysubs_additional_content) {
    echo wp_kses_post(wpautop(wptexturize($arraysubs_additional_content)));
}

/*
 * @hooked WC_Emails::email_footer() Output the email footer
 */
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WooCommerce core hook
do_action('woocommerce_email_footer', $arraysubs_email);
