<?php

/**
 * Customer Trial Started email (plain text)
 *
 * @package ArraySubs\Features\Emails\templates\plain
 * @version 1.0.0
 */

defined('ABSPATH') || exit;

echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n";
echo esc_html(wp_strip_all_tags($arraysubs_email_heading));
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";

printf(
    /* translators: %s: Customer first name */
    esc_html__('Hi %s,', 'arraysubs'),
    esc_html($arraysubs_customer['first_name'])
);
echo "\n\n";

printf(
    /* translators: %s: Product name */
    esc_html__('Your free trial for %s has started! Enjoy full access during your trial period.', 'arraysubs'),
    esc_html($arraysubs_product ? $arraysubs_product->get_name() : __('N/A', 'arraysubs'))
);
echo "\n\n";

echo "----------\n";
echo esc_html__('TRIAL DETAILS', 'arraysubs') . "\n";
echo "----------\n\n";

echo esc_html__('Subscription ID: ', 'arraysubs') . '#' . esc_html($arraysubs_subscription_id) . "\n";
echo esc_html__('Product: ', 'arraysubs') . esc_html($arraysubs_product ? $arraysubs_product->get_name() : __('N/A', 'arraysubs')) . "\n";

if (!empty($arraysubs_trial_length) && !empty($arraysubs_trial_period)) {
    echo esc_html__('Trial Length: ', 'arraysubs') . esc_html(\arraysubs_format_date_interval((int) $arraysubs_trial_length, $arraysubs_trial_period ?: 'day')) . "\n";
}

if (!empty($arraysubs_trial_end_date)) {
    echo esc_html__('Trial Ends On: ', 'arraysubs') . esc_html(\arraysubs_format_date_local($arraysubs_trial_end_date)) . "\n";
}

echo "\n";
echo esc_html__('When your trial ends, your subscription will automatically convert to a paid subscription and your payment method will be charged.', 'arraysubs');
echo "\n\n";

echo esc_html__('Manage your subscription here: ', 'arraysubs');
echo esc_url(wc_get_endpoint_url('subscriptions', '', wc_get_page_permalink('myaccount')));
echo "\n\n";

/**
 * Show user-defined additional content - this is set in each email's settings.
 */
if ($arraysubs_additional_content) {
    echo "----------\n\n";
    echo esc_html(wp_strip_all_tags(wptexturize($arraysubs_additional_content)));
    echo "\n\n";
}

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WooCommerce core hook
echo wp_kses_post(apply_filters('woocommerce_email_footer_text', get_option('woocommerce_email_footer_text')));
