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

defined( 'ABSPATH' ) || exit;

$mail_doctor_defaults = array(
	'subject' => 'New order {{order_number}} placed on {{shop_name}}',
	'heading' => 'New order received',
	'html'    => '<div class="wpmd-email">' .
		'<div class="wpmd-email__logo">{{shop_brand}}</div>' .
		'<h1>{{heading}}</h1>' .
		'<p>An order has been placed by {{customer_name}}.</p>' .
		'<p><strong>Order number:</strong> {{order_number}}</p>' .
		'<p><strong>Order total:</strong> {{order_total}}</p>' .
		'<div class="wpmd-email__table">' .
		'{{items_table}}' .
		'</div>' .
		'<p><strong>Billing:</strong><br>{{billing_address}}</p>' .
		'<p><strong>Shipping:</strong><br>{{shipping_address}}</p>' .
		'</div>',
	'css'     => '.wpmd-email{font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;padding:24px;background:#ffffff;color:#111827;}' .
		'.wpmd-email h1{margin-top:0;font-size:22px;color:#0b7285;}' .
		'.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:20px 0;}' .
		'.wpmd-items-table{width:100%;border-collapse:collapse;}' .
		'.wpmd-items-table th{background:#f1f5f9;padding:8px;text-align:left;border-bottom:1px solid #d1d5db;}' .
		'.wpmd-items-table td{padding:8px;border-bottom:1px solid #e5e7eb;}' .
		'.wpmd-items-table tfoot th,.wpmd-items-table tfoot td{font-weight:600;background:#f9fafb;}',
);

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