<?php

/**
 * Customer Trial Started email
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-trial-started.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 $trial_end_date Trial end date.
 * @var string $trial_length Trial length.
 * @var string $trial_period Trial period.
 * @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'] ?: __('there', 'arraysubs'))
    );
    ?>
    </p>

<p>
<?php
    printf(
        /* translators: %s: Product name */
        esc_html__('Your free trial for %s has started! Enjoy full access during your trial period.', 'arraysubs'),
        '<strong>' . esc_html($arraysubs_product_name) . '</strong>'
    );
    ?>
    </p>

<h2><?php esc_html_e('Trial 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_number); ?>
            </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_name); ?>
            </td>
        </tr>
        <?php if (!empty($arraysubs_trial_length) && !empty($arraysubs_trial_period)) : ?>
            <tr>
                <th class="td" scope="row" style="text-align:left;">
                    <?php esc_html_e('Trial Length', 'arraysubs'); ?>
                </th>
                <td class="td" style="text-align:left;">
                    <?php echo esc_html(\arraysubs_format_date_interval((int) $arraysubs_trial_length, $arraysubs_trial_period ?: 'day')); ?>
                </td>
            </tr>
        <?php endif; ?>
        <?php if (!empty($arraysubs_trial_end_date)) : ?>
            <tr>
                <th class="td" scope="row" style="text-align:left;">
                    <?php esc_html_e('Trial Ends On', 'arraysubs'); ?>
                </th>
                <td class="td" style="text-align:left;">
                    <?php echo esc_html(\arraysubs_format_date_local($arraysubs_trial_end_date)); ?>
                </td>
            </tr>
        <?php endif; ?>
        <tr>
            <th class="td" scope="row" style="text-align:left;">
                <?php esc_html_e('Post-Trial 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>
    </tbody>
</table>

<p style="margin-top: 20px;">
    <?php esc_html_e('When your trial ends, your subscription will automatically convert to a paid subscription and your payment method will be charged.', 'arraysubs'); ?>
</p>

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