<?php
/**
 * Back-in-stock notification email template.
 *
 * Available variables:
 *   $email_heading  - Email heading text.
 *   $product_name   - Product name.
 *   $product_url    - Product permalink.
 *   $product_image  - Product image URL.
 *   $product_price  - Product price HTML.
 *   $show_image     - Whether to show product image.
 *   $show_price     - Whether to show price.
 *   $show_cta       - Whether to show CTA button.
 *   $unsubscribe_url - Unsubscribe link URL.
 *   $email          - WC_Email object or null.
 *
 * @package Waitlytics
 */

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

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_email_header', $email_heading, $email );
?>

<p><?php
	printf(
		/* translators: %s: product name */
		esc_html__( 'Great news! %s is back in stock and ready to order.', 'waitlytics' ),
		esc_html( $product_name )
	);
?></p>

<?php if ( $show_image && $product_image ) : ?>
<div style="text-align: center; margin: 20px 0;">
	<img src="<?php echo esc_url( $product_image ); ?>"
		 alt="<?php echo esc_attr( $product_name ); ?>"
		 style="max-width: 300px; height: auto;">
</div>
<?php endif; ?>

<?php if ( $show_price ) : ?>
<p style="font-size: 18px; font-weight: bold; text-align: center;">
	<?php echo wp_kses_post( $product_price ); ?>
</p>
<?php endif; ?>

<?php if ( $show_cta ) : ?>
<div style="text-align: center; margin: 25px 0;">
	<a href="<?php echo esc_url( $product_url ); ?>"
	   style="background: #0073aa; color: #ffffff; padding: 12px 30px; text-decoration: none; border-radius: 4px; font-size: 16px; display: inline-block;">
		<?php esc_html_e( 'Buy Now', 'waitlytics' ); ?>
	</a>
</div>
<?php endif; ?>

<p style="font-size: 12px; color: #666; text-align: center; margin-top: 30px;">
	<a href="<?php echo esc_url( $unsubscribe_url ); ?>" style="color: #666;">
		<?php esc_html_e( 'Unsubscribe from this notification', 'waitlytics' ); ?>
	</a>
</p>

<?php
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_email_footer', $email );
