<?php
/**
 * Default customer invoice email template.
 *
 * @package MailDoctor
 */

defined( 'ABSPATH' ) || exit;

$mail_doctor_defaults = array(
	'subject' => 'Invoice for your order {{order_number}}',
	'heading' => 'Invoice from {{shop_name}}',
	'html'    => '<div class="wpmd-email">' .
		'<div class="wpmd-email__logo">{{shop_brand}}</div>' .
		'<h1>{{heading}}</h1>' .
		'<p>Hello {{customer_name}}, here is the latest invoice for your order.</p>' .
		'<p><strong>Order number:</strong> {{order_number}}</p>' .
		'<p><strong>Total due:</strong> {{order_total}}</p>' .
		'<p><strong>Payment method:</strong> {{payment_method}}</p>' .
		'<div class="wpmd-email__table">' .
		'{{items_table}}' .
		'</div>' .
		'<p>If you need to pay for this order, sign in to {{site_url}}.</p>' .
		'</div>',
	'css'     => '.wpmd-email{font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;padding:24px;background:#f8fafc;color:#0f172a;}' .
		'.wpmd-email h1{margin-top:0;font-size:24px;color:#0f766e;}' .
		'.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{padding:8px;background:#ecfeff;text-align:left;border-bottom:1px solid #ccfbf1;}' .
		'.wpmd-items-table td{padding:8px;border-bottom:1px solid #d1d5db;}' .
		'.wpmd-items-table tfoot th,.wpmd-items-table tfoot td{font-weight:600;background:#e0f2f1;}',
);

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(
		'customer_invoice',
		$mail_doctor_order_id,
		array(
			'defaults' => $mail_doctor_defaults,
		)
	)
);
