<?php

/**
 * Admin new subscription 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: %1$s: customer name, %2$s: subscription ID */
    esc_html__('You have received a new subscription from %1$s. Subscription #%2$s details are shown below.', '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";

printf(
    /* translators: %1$s: customer name, %2$s: customer email */
    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);
printf(
    /* translators: %s: product name */
    esc_html__('Product: %s', 'arraysubs'),
    esc_html($arraysubs_product ? $arraysubs_product->get_name() : __('N/A', 'arraysubs'))
);
echo "\n";

$arraysubs_recurring_amount = get_post_meta($arraysubs_subscription_id, '_recurring_amount', true);
$arraysubs_interval = get_post_meta($arraysubs_subscription_id, '_billing_interval', true);
$arraysubs_period = get_post_meta($arraysubs_subscription_id, '_billing_period', true);
printf(
    /* translators: 1: price, 2: billing period */
    esc_html__('Recurring Amount: %1$s / %2$s', 'arraysubs'),
    esc_html(wp_strip_all_tags(wc_price($arraysubs_recurring_amount))),
    esc_html(arraysubs_format_billing_period($arraysubs_interval, $arraysubs_period))
);
echo "\n";

$arraysubs_start_date = get_post_meta($arraysubs_subscription_id, '_start_date', true);
printf(
    /* translators: %s: start date */
    esc_html__('Start Date: %s', 'arraysubs'),
    esc_html(arraysubs_format_date_local($arraysubs_start_date))
);
echo "\n";

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

$arraysubs_payment_method_title = get_post_meta($arraysubs_subscription_id, '_payment_method_title', true);
printf(
    /* translators: %s: payment method name */
    esc_html__('Payment Method: %s', 'arraysubs'),
    esc_html($arraysubs_payment_method_title ?: __('N/A', 'arraysubs'))
);
echo "\n\n";

printf(
    /* translators: %s: link to subscription in admin */
    esc_html__('View Subscription: %s', 'arraysubs'),
    esc_url(admin_url('admin.php?page=arraysubs#/subscriptions/' . $arraysubs_subscription_id))
);

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