<?php

/**
 * Customer retention discount accepted 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: 1: offer title, 2: product name */
    esc_html__('You accepted our %1$s for %2$s, and your discount is now active.', 'arraysubs'),
    esc_html($arraysubs_offer_title),
    esc_html($arraysubs_product ? $arraysubs_product->get_name() : __('your subscription', 'arraysubs'))
);
echo "\n\n";

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

echo esc_html__('Subscription ID: ', 'arraysubs') . '#' . esc_html($arraysubs_subscription_id) . "\n";
echo esc_html__('Offer: ', 'arraysubs') . esc_html($arraysubs_offer_title) . "\n";
echo esc_html__('Discount: ', 'arraysubs') . esc_html($arraysubs_discount_value) . "\n";
echo esc_html__('Previous recurring amount: ', 'arraysubs') . wp_strip_all_tags($arraysubs_base_recurring_amount) . "\n";
echo esc_html__('New recurring amount: ', 'arraysubs') . wp_strip_all_tags($arraysubs_discounted_recurring_amount) . "\n";
echo esc_html__('Savings per renewal: ', 'arraysubs') . wp_strip_all_tags($arraysubs_savings_per_renewal) . "\n";

printf(
    /* translators: %s: number of renewals */
    esc_html(_n('Applies to: Your next %s renewal', 'Applies to: Your next %s renewals', (int) $arraysubs_discount_duration, 'arraysubs')),
    esc_html(number_format_i18n((int) $arraysubs_discount_duration))
);
echo "\n";

if (!empty($arraysubs_next_payment_date) && $arraysubs_next_payment_date !== __('N/A', 'arraysubs')) {
    echo esc_html__('Next payment date: ', 'arraysubs') . esc_html($arraysubs_next_payment_date) . "\n";
}

echo "\n";
esc_html_e('We’ve updated your subscription, and future eligible renewals will use this discounted amount automatically.', 'arraysubs');
echo "\n\n";

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

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')));
