<?php
/**
 * Warranty Reminder Email Template (Plain Text)
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/warranty-reminder.php
 *
 * @package WarrantyCart
 * @var WC_Order         $order              The order object.
 * @var string           $expiration_date    The warranty expiration date.
 * @var int              $days_remaining     Days until expiration.
 * @var string           $email_heading      The email heading.
 * @var string           $additional_content Additional content.
 * @var bool             $sent_to_admin      Whether sent to admin.
 * @var bool             $plain_text         Whether plain text.
 * @var WarrantyReminder $email              The email object.
 */

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Email template variables and WooCommerce hooks are local scope and don't need prefixing

use WarrantyCart\Notifications\Emails\WarrantyReminder;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

echo '= ' . esc_html( $email_heading ) . " =\n\n";

/* translators: %s: Customer first name */
printf( esc_html( __( 'Dear %s,', 'warranty-cart' ) ), esc_html( $order->get_billing_first_name() ) ) . "\n\n";

echo esc_html( __( 'This is a friendly reminder about your warranty coverage.', 'warranty-cart' ) ) . "\n\n";

echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";

echo esc_html( __( 'Warranty Information', 'warranty-cart' ) ) . "\n";
echo esc_html( __( 'Order Number:', 'warranty-cart' ) ) . ' #' . esc_html( $order->get_order_number() ) . "\n";
echo esc_html( __( 'Expiration Date:', 'warranty-cart' ) ) . ' ' . esc_html( date_i18n( get_option( 'date_format' ), strtotime( $expiration_date ) ) ) . "\n";
echo esc_html( __( 'Days Remaining:', 'warranty-cart' ) ) . ' ' . esc_html( $days_remaining ) . ' ' . esc_html( __( 'days', 'warranty-cart' ) ) . "\n\n";

echo esc_html( __( 'Your warranty is approaching its expiration date. To ensure continued coverage, please consider renewing your warranty or contacting us for assistance.', 'warranty-cart' ) ) . "\n\n";

echo esc_html( __( 'Covered Products', 'warranty-cart' ) ) . "\n\n";

foreach ( $order->get_items() as $item_id => $item ) :
	$product = $item->get_product();
	if ( $product && has_term( 'warranties', 'product_cat', $product->get_id() ) ) :
		echo '- ' . wp_kses_post( $item->get_name() );
		if ( $product->get_sku() ) {
			echo ' (#' . esc_html( $product->get_sku() ) . ')';
		}
		echo "\n";
		endif;
	endforeach;

echo "\n" . esc_html( __( 'If you have any questions about your warranty coverage or need assistance, please don\'t hesitate to contact our support team.', 'warranty-cart' ) ) . "\n\n";

if ( $additional_content ) {
	echo esc_html( wp_strip_all_tags( wptexturize( $additional_content ) ) ) . "\n\n";
}

echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";

echo esc_html( apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ) );
// phpcs:enable
