<?php
/**
 * The template for displaying the box opened at info in the loop for win context.
 * This template can be overridden by copying it to yourtheme/woocommerce/mysterx/opened-info.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://woocommerce.com/document/template-structure/
 * @package WooCommerce\Templates
 * @version 9.4.0
 */

defined( 'ABSPATH' ) || exit;

global $product, $myster_win;

if ( ! $myster_win || ! $product ) {
	return;
}

$value = $product->get_meta( 'mysterx_opened_at' );

if ( $value ) {

	$dateformat = get_option( 'date_format' );
	$timeformat = get_option( 'time_format' );
	?>
			<p class="opened_box_at">
				<span class='text'><?php echo esc_html__( 'Opened at: ', 'mysterx-mystery-boxes-for-woocommerce' ); ?></span>
				<span class='date'><?php echo esc_html( date_i18n( $dateformat, strtotime( $value ) ) ); ?><span>
				<span class='time'><?php echo esc_html( date_i18n( $timeformat, strtotime( $value ) ) ); ?><span>
			</p>
			<?php
}
