<?php

/**
 * Customer auto-downgrade email (plain text)
 *
 * @package ArraySubs\Features\Emails\templates\plain
 * @version 1.7.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'] ?: __('there', 'arraysubs'))
);
echo "\n\n";

printf(
    /* translators: %s: subscription ID */
    esc_html__('Your subscription #%s has been automatically updated to a new plan.', 'arraysubs'),
    esc_html($arraysubs_subscription_id)
);
echo "\n\n";

echo "----------\n";
printf(
    /* translators: %s: Subscription ID */
    esc_html__('Subscription #%s', 'arraysubs'),
    esc_html($arraysubs_subscription_id)
);
echo "\n----------\n\n";

$arraysubs_old_name = $arraysubs_old_product
    ? arraysubs_get_subscription_product_name($arraysubs_old_product)
    : '#' . $arraysubs_old_product_id;
$arraysubs_new_name = $arraysubs_new_product
    ? arraysubs_get_subscription_product_name($arraysubs_new_product)
    : '#' . $arraysubs_new_product_id;

/* translators: %s: plan name */
printf(esc_html__('Previous Plan: %s', 'arraysubs'), esc_html($arraysubs_old_name));
echo "\n";

/* translators: %s: plan name */
printf(esc_html__('New Plan: %s', 'arraysubs'), esc_html($arraysubs_new_name));
echo "\n";

/* translators: %s: subscription status */
printf(esc_html__('Status: %s', 'arraysubs'), esc_html__('Active', 'arraysubs'));
echo "\n";

$arraysubs_next_payment = get_post_meta($arraysubs_subscription_id, '_next_payment_date', true);
if (!empty($arraysubs_next_payment)) {
    /* translators: %s: next payment date */
    printf(esc_html__('Next Payment: %s', 'arraysubs'), esc_html(arraysubs_format_date_local($arraysubs_next_payment)));
    echo "\n";
}

echo "\n";
esc_html_e('Your subscription has been automatically adjusted to keep your access active. No action is needed on your part.', 'arraysubs');
echo "\n\n";

/* translators: %s: My Account subscription URL */
printf(esc_html__('View your subscription: %s', 'arraysubs'), esc_url(wc_get_account_endpoint_url('subscriptions')));
echo "\n\n";

if ($arraysubs_additional_content) {
    echo "---\n\n";
    echo esc_html(wp_strip_all_tags(wptexturize($arraysubs_additional_content)));
    echo "\n\n";
}
