<?php

/**
 * Customer subscription pending cancellation email
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-subscription-pending-cancellation.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
    if (!empty($arraysubs_scheduled_cancel_date)) {
        printf(
            /* translators: 1: subscription ID, 2: scheduled cancellation date */
            esc_html__('Your subscription #%1$s is scheduled to cancel on %2$s. You will continue to have access until that date, after which no further payments will be charged.', 'arraysubs'),
            esc_html($arraysubs_subscription_id),
            '<strong>' . esc_html($arraysubs_scheduled_cancel_date) . '</strong>'
        );
    } else {
        printf(
            /* translators: %s: subscription ID */
            esc_html__('Your subscription #%s is scheduled to cancel at the end of the current billing period. You will continue to have access until then, after which no further payments will be charged.', 'arraysubs'),
            esc_html($arraysubs_subscription_id)
        );
    }
    ?>
</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('Status', 'arraysubs'); ?></th>
            <td class="td" style="text-align: left; color: #c79a00; font-weight: bold;">
                <?php esc_html_e('Scheduled to cancel', 'arraysubs'); ?>
            </td>
        </tr>
        <?php if (!empty($arraysubs_scheduled_cancel_date)) : ?>
            <tr>
                <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Cancellation Date', 'arraysubs'); ?></th>
                <td class="td" style="text-align: left;">
                    <?php echo esc_html($arraysubs_scheduled_cancel_date); ?>
                </td>
            </tr>
        <?php endif; ?>
        <?php if (!empty($arraysubs_cancellation_reason)) : ?>
            <tr>
                <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Reason', 'arraysubs'); ?></th>
                <td class="td" style="text-align: left;">
                    <?php echo esc_html($arraysubs_cancellation_reason); ?>
                </td>
            </tr>
        <?php endif; ?>
    </tbody>
</table>

<?php if (!empty($arraysubs_view_subscription_url)) : ?>
    <p>
        <?php esc_html_e('Changed your mind? You can undo the scheduled cancellation from your account at any time before the cancellation date.', 'arraysubs'); ?>
    </p>
    <p>
        <a class="link" href="<?php echo esc_url($arraysubs_view_subscription_url); ?>">
            <?php esc_html_e('Manage subscription', 'arraysubs'); ?>
        </a>
    </p>
<?php endif; ?>

<?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);
