<?php
/**
 * Cart items table shown in recovery emails.
 *
 * This template can be overridden by copying it to yourtheme/cartninja/emails/cartninja-cart-items.php.
 *
 * @package CartNinjaRecovery
 */

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

$text_align = is_rtl() ? 'right' : 'left';

if ( empty( $cart_items ) ) {
	return;
}
?>

<h2><?php esc_html_e( 'Cart summary', 'cartninja-recovery-for-woocommerce' ); ?></h2>

<div style="margin-bottom: 32px;">
	<table class="td font-family" cellspacing="0" cellpadding="6" style="width: 100%;" border="1">
		<thead>
			<tr>
				<th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'cartninja-recovery-for-woocommerce' ); ?></th>
				<th class="td" scope="col" style="text-align:center;"><?php esc_html_e( 'Quantity', 'cartninja-recovery-for-woocommerce' ); ?></th>
				<th class="td" scope="col" style="text-align:right;"><?php esc_html_e( 'Price', 'cartninja-recovery-for-woocommerce' ); ?></th>
			</tr>
		</thead>
		<tbody>
			<?php foreach ( $cart_items as $item ) : ?>
				<tr>
					<td class="td font-family" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; word-wrap:break-word;">
						<table role="presentation" cellspacing="0" cellpadding="0" style="width:100%;">
							<tr>
								<?php if ( ! empty( $item['image'] ) ) : ?>
									<td style="vertical-align:top; width:56px;"><?php echo wp_kses_post( $item['image'] ); ?></td>
								<?php endif; ?>
								<td style="vertical-align:top;">
									<strong><?php echo esc_html( $item['name'] ); ?></strong>
									<?php if ( ! empty( $item['variation'] ) ) : ?>
										<br><small><?php echo esc_html( $item['variation'] ); ?></small>
									<?php endif; ?>
								</td>
							</tr>
						</table>
					</td>
					<td class="td font-family" style="text-align:center; vertical-align:middle;"><?php echo esc_html( $item['quantity'] ); ?></td>
					<td class="td font-family" style="text-align:right; vertical-align:middle;"><?php echo wp_kses_post( $item['line_total'] ); ?></td>
				</tr>
			<?php endforeach; ?>
			<tr>
				<th class="td font-family" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>; border-top-width:4px;">
					<?php esc_html_e( 'Cart total', 'cartninja-recovery-for-woocommerce' ); ?>
				</th>
				<td class="td font-family" style="text-align:right; border-top-width:4px;"><?php echo esc_html( $cart_total ); ?></td>
			</tr>
		</tbody>
	</table>
</div>
