<?php

/**
 * Customer retention discount accepted email.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-retention-discount-accepted.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'])
    );
    ?>
</p>

<p>
    <?php
    printf(
        /* translators: 1: offer title, 2: product name */
        esc_html__('You accepted our %1$s for %2$s, and your discount is now active.', 'arraysubs'),
        '<strong>' . esc_html($arraysubs_offer_title) . '</strong>',
        '<strong>' . esc_html($arraysubs_product ? $arraysubs_product->get_name() : __('your subscription', 'arraysubs')) . '</strong>'
    );
    ?>
</p>

<h2><?php esc_html_e('Discount 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('Offer', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left;">
                <?php echo esc_html($arraysubs_offer_title); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align:left;">
                <?php esc_html_e('Discount', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left;">
                <?php echo esc_html($arraysubs_discount_value); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align:left;">
                <?php esc_html_e('Previous recurring amount', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left;">
                <?php echo wp_kses_post($arraysubs_base_recurring_amount); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align:left;">
                <?php esc_html_e('New recurring amount', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left;">
                <?php echo wp_kses_post($arraysubs_discounted_recurring_amount); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align:left;">
                <?php esc_html_e('Savings per renewal', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left;">
                <?php echo wp_kses_post($arraysubs_savings_per_renewal); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align:left;">
                <?php esc_html_e('Applies to', 'arraysubs'); ?>
            </th>
            <td class="td" style="text-align:left;">
                <?php
                printf(
                    /* translators: %s: number of renewals */
                    esc_html(_n('Your next %s renewal', 'Your next %s renewals', (int) $arraysubs_discount_duration, 'arraysubs')),
                    esc_html(number_format_i18n((int) $arraysubs_discount_duration))
                );
                ?>
            </td>
        </tr>
        <?php if (!empty($arraysubs_next_payment_date) && $arraysubs_next_payment_date !== __('N/A', 'arraysubs')) : ?>
            <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 echo esc_html($arraysubs_next_payment_date); ?>
                </td>
            </tr>
        <?php endif; ?>
    </tbody>
</table>

<p style="margin-top: 20px;">
    <?php esc_html_e('We’ve updated your subscription, and future eligible renewals will use this discounted amount automatically.', 'arraysubs'); ?>
</p>

<p>
    <a href="<?php echo esc_url(wc_get_endpoint_url('subscriptions', '', wc_get_page_permalink('myaccount'))); ?>" class="button" style="display: inline-block; padding: 12px 24px; background-color: #96588a; color: #ffffff; text-decoration: none; border-radius: 4px;">
        <?php esc_html_e('View 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);
