<?php
/**
 * Mysterx boc product add to cart
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/mysterx.php.
 *
 * @package Mysterx/templates
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}
global $product;
if ( ! mysterx_check_if_user_can_open_box( get_current_user_id(), $product->get_id() ) ) {
	return;
}
echo '<p class="mysterx-boxes-left" data-product_id="' . esc_attr( $product->get_id() ) . '">';
echo esc_html(
	sprintf(
		/* translators: %d: number of boxes left to open */
		_n( 'You have %d box left to open', 'You have %d boxes left to open', $product->get_number_of_boxses_for_openning_for_user( get_current_user_id() ), 'mysterx-mystery-boxes-for-woocommerce' ),
		$product->get_number_of_boxses_for_openning_for_user( get_current_user_id() )
	)
);
echo '</p>';
?>
<?php if ( $product->is_there_reward() ) : ?>
	<a href="<?php echo esc_url( $product->open_box_url() ); ?>" class="open-box-button button alt multiple-open" data-product_id="<?php echo esc_attr( $product->get_id() ); ?>"><?php esc_html_e( 'Click here to open', 'mysterx-mystery-boxes-for-woocommerce' ); ?></a>
<?php endif; ?>
