<?php
/**
 * Thankyou page
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/thankyou.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce\Templates
 * @version 3.7.0
 */

defined( 'ABSPATH' ) || exit;
?>
<?php if (is_page_template('fullwidth.php') || is_page_template('container.php')) : ?>
<div class="wrapper<?php echo esc_attr(is_page_template('fullwidth.php') ? ' read' : '') ?> checkout">
	<div class="ui container">
<?php endif; ?>
		<div class="woocommerce-order">

			<?php
			if ( $order ) :

				do_action( 'woocommerce_before_thankyou', $order->get_id() );
				?>

				<?php if ( $order->has_status( 'failed' ) ) : ?>

					<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed"><?php esc_html_e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'campoal' ); ?></p>

					<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed-actions">
						<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php esc_html_e( 'Pay', 'campoal' ); ?></a>
						<?php if ( is_user_logged_in() ) : ?>
							<a href="<?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?>" class="button pay"><?php esc_html_e( 'My account', 'campoal' ); ?></a>
						<?php endif; ?>
					</p>

				<?php else : ?>
					<div class="ui basic center aligned segment">
						<h1 class="ui icon green header woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received">
                            <i class="circular checkmark icon"></i>
							<?php echo apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'campoal' ), $order ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
							<div class="sub header">
								<?php echo apply_filters( 'woocommerce_thankyou_order_received_desc', sprintf( esc_html__( 'Your order has been successfully. You will receive a confirmation email via %s.', 'campoal' ), $order->get_billing_email() ), $order ); ?>
							</div>
						</h1>
					</div>
					<div class="ui section hidden divider"></div>
					<div class="ui secondary segment">
						<div class="ui four column internally celled stackable grid woocommerce-order-overview woocommerce-thankyou-order-details order_details">
							<div class="row">
								<div class="column woocommerce-order-overview__order order">
									<div class="ui medium header">
										<div class="sub header"><?php esc_html_e( 'Order number:', 'campoal' ); ?></div>
										<?php echo esc_html($order->get_order_number()); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
									</div>
								</div>

								<div class="column woocommerce-order-overview__date date">
									<div class="ui medium header">
										<div class="sub header"><?php esc_html_e( 'Date:', 'campoal' ); ?></div>
										<?php echo wc_format_datetime( $order->get_date_created() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
									</div>
								</div>

								<?php if ( $order->get_payment_method_title() ) : ?>
									<div class="column woocommerce-order-overview__date date">
										<div class="ui medium header">
											<div class="sub header"><?php esc_html_e( 'Payment method:', 'campoal' ); ?></div>
											<?php echo wp_kses_post( $order->get_payment_method_title() ); ?>
										</div>
									</div>
								<?php endif; ?>

								<div class="column woocommerce-order-overview__date date">
									<div class="ui medium header">
										<div class="sub header"><?php esc_html_e( 'Total:', 'campoal' ); ?></div>
										<?php echo wp_kses_post($order->get_formatted_order_total()); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
									</div>
								</div>

							</div>
						</div>
					</div>
					<div class="ui section hidden divider"></div>
				<?php endif; ?>

				<?php do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order->get_id() ); ?>
				<div class="ui section hidden divider"></div>
				<?php do_action( 'woocommerce_thankyou', $order->get_id() ); ?>

			<?php else : ?>

				<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'campoal' ), null ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>

			<?php endif; ?>

			<?php if ( wc_get_page_id( 'shop' ) > 0 ) : ?>
				<div class="aligncenter">
					<a class="ui big primary circular button" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
						<?php esc_html_e( 'Continue Shopping', 'campoal' ) ?>
						<i class="angle right icon"></i>
					</a>
				</div>
			<?php endif; ?>

		</div>
<?php if (is_page_template('fullwidth.php') || is_page_template('container.php')) : ?>
	</div>
</div>
<?php endif; ?>