<?php
/**
 * Find a warranty without an account.
 *
 * The form that takes an order number and an email address. Everything it finds
 * is drawn by the frontend bundle, because until the customer has proved which
 * order is theirs there is nothing to show.
 *
 * @package WarrantyCart
 * @version 2.1.0
 */

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

?>
<div class="warranty-guest" id="warranty-guest">
	<form class="warranty-guest__lookup" id="warranty-guest-lookup">
		<h3 class="warranty-guest__title"><?php \esc_html_e( 'Find your warranty', 'warranty-cart' ); ?></h3>

		<p class="warranty-guest__intro">
			<?php \esc_html_e( 'Enter the order number from your confirmation email, and the address you ordered with.', 'warranty-cart' ); ?>
		</p>

		<p class="form-row">
			<label for="warranty-guest-order">
				<?php \esc_html_e( 'Order number', 'warranty-cart' ); ?>
				<span class="required">*</span>
			</label>
			<input type="text" id="warranty-guest-order" name="order_id" inputmode="numeric" required>
		</p>

		<p class="form-row">
			<label for="warranty-guest-email">
				<?php \esc_html_e( 'Email address', 'warranty-cart' ); ?>
				<span class="required">*</span>
			</label>
			<input type="email" id="warranty-guest-email" name="email" autocomplete="email" required>
		</p>

		<p class="form-row">
			<button type="submit" class="button alt" id="warranty-guest-submit">
				<?php \esc_html_e( 'Find my warranties', 'warranty-cart' ); ?>
			</button>
		</p>
	</form>

	<?php /* Where the lookup reports what it found, or why it did not. */ ?>
	<div class="warranty-guest__notice" role="status" aria-live="polite" hidden></div>

	<div class="warranty-guest__results" id="warranty-guest-results" hidden></div>

	<?php
	/*
	 * The same claim form the account page uses.
	 *
	 * Shared rather than copied: two forms would be two sets of field IDs for
	 * one handler to bind to, and the mandatory-proof rule would have to be
	 * remembered in both.
	 */
	\wc_get_template(
		'frontend/my-account-claim-form.php',
		array(),
		'warranty-cart',
		WARRANTY_CART_PATH . 'templates/'
	);
	?>
</div>
