<?php

/**
 * Customer subscription cancelled 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'] ?: __('there', 'arraysubs'))
);
echo "\n\n";

printf(
    /* translators: %s: subscription ID */
    esc_html__('Your subscription #%s has been cancelled.', '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_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__('Cancelled', 'arraysubs'));
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";

esc_html_e('Your access to the subscription benefits has ended. If you change your mind, you can always subscribe again.', 'arraysubs');
echo "\n\n";

printf(
    /* translators: %s: shop URL */
    esc_html__('Browse our products: %s', 'arraysubs'),
    esc_url(wc_get_page_permalink('shop'))
);
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')));
