<?php /* Template Name: Thank-you shortcode */

use Prodigy\Includes\Helpers\Prodigy_Formatting;
use Prodigy\Includes\Helpers\Prodigy_Url_Helper;

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

<div class="prodigy-custom-template">
	<div class="container prodigy-thank-you-page">
		<div class="row mb-80">
			<div class="col-12 pl-0 pr-0">
				<div class="d-flex flex-column align-items-center">
					<?php if ( ( $divi_editor || ! empty( $order_info ) ) && ! $test_preview ) : ?>
						<h1 class="prodigy-thank-you-page__title">
							<?php echo esc_html( $args['message'] ?? '' ); ?>
						</h1>
						<div class="prodigy-thank-you-page__txt prodigy-thanks-txt__content">
							<p class="mb-0 text-center">
								<?php
								$body_template = $args['body_text'] ?? 'Order [order number] was successfully placed.';
								$order_number  = '<span class="font-bold">#' . esc_html( $order_remote ) . '</span>';
								$order_message = wp_kses( str_replace( '[order number]', $order_number, $body_template ), Prodigy_Formatting::get_allowed_html() );
								echo $order_message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
								?>
							</p>
						</div>
						<?php if ( $is_approval ) : ?>
							<h2 class="prodigy-thank-you-page__approval-message">
								<?php esc_html_e( 'Your order has been sent for approval.', 'prodigy-commerce' ); ?>
								<br class="d-md-none"/>
								<?php esc_html_e( ' You will receive an email with a reply.', 'prodigy-commerce' ); ?>
							</h2>
						<?php endif; ?>
					<?php else : ?>
						<h1 class="prodigy-thank-you-page__title">
							<?php esc_html_e( 'This order', 'prodigy-commerce' ); ?>
							<br class="d-md-none">
							<?php esc_html_e( ' does not exist.', 'prodigy-commerce' ); ?>
						</h1>
						<?php if ( $is_approval ) : ?>
							<h2 class="prodigy-thank-you-page__approval-message">
								<?php esc_html_e( 'Your order has been sent for approval.', 'prodigy-commerce' ); ?>
								<br class="d-md-none"/>
								<?php esc_html_e( ' You will receive an email with a reply.', 'prodigy-commerce' ); ?>
							</h2>
						<?php endif; ?>
					<?php endif; ?>
					<?php if ( $args['show_back_button'] ?? true ) : ?>
						<a class="prodigy-main-button prodigy-main-button--link prodigy-main-button--wide prodigy-thanks-txt__content"
							href="<?php echo esc_url( Prodigy_Url_Helper::prodigy_get_shop_url() ); ?>">
							<?php echo esc_html( $args['button_text'] ?? 'BACK TO SHOP LIST' ); ?>
						</a>
					<?php endif; ?>
				</div>
			</div>
		</div>
	</div>
</div>

<script
		src="<?php echo esc_url( plugin_dir_url( PRODIGY_PLUGIN_PATH . '/includes/frontend/shortcodes/js/feature-products.js' ) ) . 'feature-products.js'; ?>">
</script>
