<?php
/**
 * Warranty Expired Email Template (Plain Text)
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/warranty-expired.php
 *
 * @package WarrantyCart
 * @var WC_Order        $order              The order object.
 * @var string          $expiration_date    The warranty expiration date.
 * @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 WarrantyExpired $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
 */

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( __( 'We hope this email finds you well. We wanted to inform you that your warranty coverage has now expired.', 'warranty-cart' ) ) . "\n\n";

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

echo esc_html( __( 'Warranty Status', '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( __( 'Status:', 'warranty-cart' ) ) . ' ' . esc_html( __( 'Expired', 'warranty-cart' ) ) . "\n\n";

echo esc_html( __( 'Your warranty coverage for the following products has now expired. While your warranty is no longer active, we\'re still here to help with any questions or support you may need.', 'warranty-cart' ) ) . "\n\n";

echo esc_html( __( 'Expired Warranty 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 ' - ' . esc_html( __( 'Purchased:', 'warranty-cart' ) ) . ' ' . esc_html( wc_format_datetime( $order->get_date_created() ) ) . "\n";
		endif;
	endforeach;

echo "\n" . esc_html( __( 'Need Extended Coverage?', 'warranty-cart' ) ) . "\n\n";

echo esc_html( __( 'If you\'d like to extend your warranty coverage or have questions about additional support options, please don\'t hesitate to contact us. We\'re here to help!', 'warranty-cart' ) ) . "\n\n";

echo esc_html( __( 'Thank you for choosing our warranty services. We appreciate your business and hope to continue serving you in the future.', '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 
