<?php

/**
 * Customer renewal reminder email
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-renewal-reminder.php.
 *
 * @package ArraySubs\Features\Emails\templates
 * @version 1.0.0
 */

defined('ABSPATH') || exit;

// 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'] ?: __('there', 'arraysubs'))
    );
    ?>
</p>

<p>
    <?php
    printf(
        /* translators: %d: days before renewal */
        esc_html__('This is a friendly reminder that your subscription will renew in %d days.', 'arraysubs'),
        absint($arraysubs_days_before)
    );
    ?>
</p>

<h2>
    <?php
    printf(
        /* translators: %s: Subscription ID */
        esc_html__('Subscription #%s', 'arraysubs'),
        esc_html($arraysubs_subscription_id)
    );
    ?>
</h2>

<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; margin-bottom: 40px;" border="1">
    <tbody>
        <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
                $arraysubs_product_id = get_post_meta($arraysubs_subscription_id, '_product_id', true);
                $arraysubs_product = wc_get_product($arraysubs_product_id);
                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('Renewal Amount', 'arraysubs'); ?></th>
            <td class="td" style="text-align: left;">
                <?php
                $arraysubs_recurring_amount = get_post_meta($arraysubs_subscription_id, '_recurring_amount', true);
                echo wp_kses_post(wc_price($arraysubs_recurring_amount));
                ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Next Payment Date', 'arraysubs'); ?></th>
            <td class="td" style="text-align: left;">
                <?php
                $arraysubs_next_payment = get_post_meta($arraysubs_subscription_id, '_next_payment_date', true);
                echo esc_html(arraysubs_format_date_local($arraysubs_next_payment));
                ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Payment Method', 'arraysubs'); ?></th>
            <td class="td" style="text-align: left;">
                <?php
                $arraysubs_payment_method_title = get_post_meta($arraysubs_subscription_id, '_payment_method_title', true);
                echo esc_html($arraysubs_payment_method_title ?: __('N/A', 'arraysubs'));
                ?>
            </td>
        </tr>
    </tbody>
</table>

<p><?php esc_html_e('Please make sure the upcoming renewal invoice is paid on time to keep your subscription active.', 'arraysubs'); ?></p>

<p>
    <a class="link" href="<?php echo esc_url(wc_get_account_endpoint_url('subscriptions')); ?>">
        <?php esc_html_e('Manage your subscription', 'arraysubs'); ?>
    </a>
</p>

<?php
if ($arraysubs_additional_content) {
    echo wp_kses_post(wpautop(wptexturize($arraysubs_additional_content)));
}

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WooCommerce core hook
do_action('woocommerce_email_footer', $arraysubs_email);
