<?php
/**
 * Default failed order email template.
 *
 * @package MailDoctor
 */

defined( 'ABSPATH' ) || exit;

$mail_doctor_defaults = array(
	'subject' => 'Payment failed for order {{order_number}}',
	'heading' => 'Payment failed',
	'html'    => '<div class="wpmd-email">' .
		'<div class="wpmd-email__logo">{{shop_brand}}</div>' .
		'<h1>{{heading}}</h1>' .
		'<p>The recent attempt to charge {{order_total}} for order {{order_number}} did not complete.</p>' .
		'<p>Please review the order details and attempt payment again using {{payment_method}}.</p>' .
		'<p><strong>Customer:</strong> {{customer_name}} ({{customer_email}})</p>' .
		'<div class="wpmd-email__table">' .
		'{{items_table}}' .
		'</div>' .
		'</div>',
	'css'     => '.wpmd-email{font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;padding:24px;background:#fff5f5;color:#7f1d1d;}' .
		'.wpmd-email h1{margin-top:0;font-size:24px;color:#b91c1c;}' .
		'.wpmd-email__logo{margin:0 0 16px;text-align:center;}' .
		'.wpmd-email__logo img{max-width:200px;height:auto;}' .
		'.wpmd-brand-text{font-weight:700;font-size:20px;color:inherit;}' .
		'.wpmd-email__table{margin:18px 0;}' .
		'.wpmd-items-table{width:100%;border-collapse:collapse;}' .
		'.wpmd-items-table th,.wpmd-items-table td{padding:8px;border-bottom:1px solid #fecaca;}' .
		'.wpmd-items-table th{background:#fee2e2;text-align:left;}',
);

global $mail_doctor_collecting_defaults;

if ( ! empty( $mail_doctor_collecting_defaults ) ) {
	return $mail_doctor_defaults;
}

$mail_doctor_order_id = 0;
if ( isset( $order ) && class_exists( 'WC_Order' ) && $order instanceof WC_Order ) {
	$mail_doctor_order_id = $order->get_id();
}

echo wp_kses_post(
	mail_doctor_render_email(
		'failed_order',
		$mail_doctor_order_id,
		array(
			'defaults' => $mail_doctor_defaults,
		)
	)
);
