<?php

/**
 * Admin payment failed 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__('The automatic renewal payment for subscription #%2$s from %1$s has failed.', '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";

if ($arraysubs_order) {
    printf(
        /* translators: %s: order number */
        esc_html__('Order: #%s', 'arraysubs'),
        esc_html($arraysubs_order->get_order_number())
    );
    echo "\n";

    printf(
        /* translators: %s: order amount */
        esc_html__('Amount: %s', 'arraysubs'),
        esc_html(wp_strip_all_tags($arraysubs_order->get_formatted_order_total()))
    );
    echo "\n";
}

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

esc_html_e('Please review the subscription and take appropriate action.', 'arraysubs');
echo "\n\n";

/* translators: %s: link to subscription in admin */
printf(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')));
