<?php

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

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

<p><?php esc_html_e('Great news! Your subscription is now active. Here are the details:', 'arraysubs'); ?></p>

<h2>
<?php
    printf(
        /* translators: %s: Subscription ID */
        esc_html__('Subscription #%s', 'arraysubs'),
        esc_html($arraysubs_subscription_number)
    );
    ?>
    </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 echo esc_html($arraysubs_product_name); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Price', 'arraysubs'); ?></th>
            <td class="td" style="text-align: left;">
                <?php echo wp_kses_post($arraysubs_recurring_amount); ?>
                /
                <?php echo esc_html($arraysubs_billing_period); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Start Date', 'arraysubs'); ?></th>
            <td class="td" style="text-align: left;">
                <?php echo esc_html($arraysubs_start_date); ?>
            </td>
        </tr>
        <tr>
            <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Next Payment', 'arraysubs'); ?></th>
            <td class="td" style="text-align: left;">
                <?php echo esc_html($arraysubs_next_payment_date); ?>
            </td>
        </tr>
        <?php
        $arraysubs_end_date = get_post_meta($arraysubs_subscription_id, '_end_date', true);
        if (!empty($arraysubs_end_date)) :
        ?>
            <tr>
                <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('End Date', 'arraysubs'); ?></th>
                <td class="td" style="text-align: left;">
                    <?php echo esc_html(arraysubs_format_date_local($arraysubs_end_date)); ?>
                </td>
            </tr>
        <?php endif; ?>
    </tbody>
</table>

<p>
    <a class="link" href="<?php echo esc_url($arraysubs_my_account_url); ?>">
        <?php esc_html_e('View your subscription', 'arraysubs'); ?>
    </a>
</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);
