<?php

/**
 * Admin subscription pending cancellation 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";

if (!empty($arraysubs_scheduled_cancel_date)) {
    printf(
        /* translators: 1: customer name, 2: subscription ID, 3: scheduled cancellation date */
        esc_html__('Subscription #%2$s from %1$s is scheduled to cancel on %3$s.', 'arraysubs'),
        esc_html($arraysubs_customer['full_name'] ?: $arraysubs_customer['email']),
        esc_html($arraysubs_subscription_id),
        esc_html($arraysubs_scheduled_cancel_date)
    );
} else {
    printf(
        /* translators: 1: customer name, 2: subscription ID */
        esc_html__('Subscription #%2$s from %1$s is scheduled to cancel at the end of the current billing period.', 'arraysubs'),
        esc_html($arraysubs_customer['full_name'] ?: $arraysubs_customer['email']),
        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";

/* translators: 1: customer full name, 2: customer email */
printf(
    esc_html__('Customer: %1$s (%2$s)', 'arraysubs'),
    esc_html($arraysubs_customer['full_name']),
    esc_html($arraysubs_customer['email'])
);
echo "\n";

$arraysubs_product_id = get_post_meta($arraysubs_subscription_id, '_product_id', true);
$arraysubs_product = wc_get_product($arraysubs_product_id);

/* translators: %s: product name */
printf(esc_html__('Product: %s', 'arraysubs'), esc_html($arraysubs_product ? $arraysubs_product->get_name() : __('N/A', 'arraysubs')));
echo "\n";

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

if (!empty($arraysubs_scheduled_cancel_date)) {
    /* translators: %s: scheduled cancellation date */
    printf(esc_html__('Cancellation Date: %s', 'arraysubs'), esc_html($arraysubs_scheduled_cancel_date));
    echo "\n";
}

if (!empty($arraysubs_cancelled_by)) {
    /* translators: %s: actor who scheduled the cancellation */
    printf(esc_html__('Scheduled By: %s', 'arraysubs'), esc_html($arraysubs_cancelled_by));
    echo "\n";
}

if (!empty($arraysubs_cancellation_reason)) {
    /* translators: %s: reason */
    printf(esc_html__('Reason: %s', 'arraysubs'), esc_html($arraysubs_cancellation_reason));
    echo "\n";
}
echo "\n";

printf(
    /* translators: %s: admin subscription URL */
    esc_html__('View subscription: %s', 'arraysubs'),
    esc_url(admin_url('admin.php?page=arraysubs#/subscriptions/' . $arraysubs_subscription_id))
);
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')));
