<?php
/**
 * Mageplaza
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Mageplaza.com license that is
 * available through the world-wide-web at this URL:
 * https://www.mageplaza.com/LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Mageplaza
 * @package     Mageplaza_AbandonedCart
 * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
 * @license     https://www.mageplaza.com/LICENSE.txt
 */

use Mageplaza\AbandonedCart\Block\Email\Template;

/** @var Template $block */

$itemCollection = $block->getProductCollection();
?>

<table class="email-items">
    <thead>
    <tr>
        <th class="item-info"><?= $block->escapeHtml(__('Image')) ?></th>
        <th class="item-info"><?= $block->escapeHtml(__('Product Name')) ?></th>
        <th class="item-qty"><?= $block->escapeHtml(__('Qty')) ?></th>
        <th class="item-price"><?= $block->escapeHtml(__('Price')) ?></th>
    </tr>
    </thead>
    <tbody>
    <?php if (!count($itemCollection)): ?>
        <tr>
            <td class="item-info">
                <span class="product-image">
                    <img src="<?= $block->escapeUrl($block->getPlaceholderImage()) ?>" alt="test"/>
                </span>
            </td>
            <td class="item-info">
                <p class="product-name"><?= $block->escapeHtml(__('Test product')) ?></p>
            </td>
            <td class="item-qty">
                <span class="product-qty">0</span>
            </td>
            <td class="item-price">
                <span class="product-price"><?= $block->escapeHtml($block->getSubtotal()) ?></span>
            </td>
        </tr>
    <?php else: ?>
        <?php foreach ($itemCollection as $_item): ?>
            <tr>
                <td class="item-info">
                    <span class="product-image">
                        <img src="<?= $block->escapeUrl($block->getProductImage($_item)) ?>"
                             alt="<?= $block->escapeHtml($_item->getName()) ?>" width="100" height="100"/>
                    </span>
                </td>
                <td class="item-info">
                    <p class="product-name">
                        <a href="<?= $block->escapeUrl($_item->getProduct()->getProductUrl()) ?>" target="_blank">
                            <?= $block->escapeHtml($_item->getName()) ?>
                        </a>
                    </p>
                </td>
                <td class="item-qty">
                    <span class="product-qty"><?= (int) $_item->getQty() ?></span>
                </td>
                <?php if (!$block->getTaxConfig()->displayCartPricesInclTax()): ?>
                    <td class="item-price">
                        <span class="product-price"><?= $block->escapeHtml($block->getProductPrice($_item)) ?></span>
                    </td>
                <?php endif; ?>
                <?php if (!$block->getTaxConfig()->displayCartPricesExclTax()): ?>
                    <td class="item-price">
                        <span class="product-price">
                            <?= $block->escapeHtml($block->getProductPrice($_item, true)) ?>
                        </span>
                    </td>
                <?php endif; ?>
            </tr>
        <?php endforeach; ?>
    <?php endif; ?>
    </tbody>
    <tfoot class="order-totals">
    <?php if (!$block->getTaxConfig()->displayCartSubtotalInclTax()): ?>
        <tr class="last-item">
            <th colspan="3" scope="row"><?= $block->escapeHtml(__('Order Total Excl. Tax')) ?></th>
            <td><?= /* @noEscape */  $block->getSubtotal() ?></td>
        </tr>
    <?php endif; ?>
    <?php if (!$block->getTaxConfig()->displayCartSubtotalExclTax()): ?>
        <tr class="last-item">
            <th colspan="3" scope="row"><?= $block->escapeHtml(__('Order Total Incl. Tax')) ?></th>
            <td><?= /* @noEscape */ $block->getSubtotal(true) ?></td>
        </tr>
    <?php endif; ?>
    </tfoot>
</table>
