<?php

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.

/**
 *
 * Won boxes shortcode template
 *
*/

if ( $boxes ) {
	?>
	<ul class="products columns-<?php echo esc_attr( wc_get_loop_prop( 'columns' ) ); ?>">

	<?php
		foreach ( $boxes as $key => $value ) {

			global $product, $post;

			$current_post = get_post( $value['reward_id'] );

			if ( $current_post ) {
				setup_postdata( $current_post );
			}

			$product = wc_get_product( $value['reward_id'] );

			wc_get_template( 'mysterx/mysterx-win.php', array( 'mysterx_opened_at' => $value['mysterx_opened_at'] ) );

		}

		wp_reset_postdata();
	?>
	</ul>
	<?php
			$args = array(
				'total'   => intval( $max_num_pages ),
				'current' => $current_page,
			);
			wc_get_template( 'loop/pagination.php', $args );


} else {
	?>

	<div class="woocommerce-message woocommerce-message--info woocommerce-Message woocommerce-Message--info woocommerce-info">
		<?php esc_html_e( 'No boxes found.', 'mysterx-mystery-boxes-for-woocommerce' ); ?>
	</div>

	<?php
}
