<?php
$productName = $block->getData('product_name');
$productSku = $block->getData('product_sku');
$productPrice = $block->getData('product_price');
$productImage = $block->getData('product_image');
$productWishlist = $block->getData('wishlist_products');
?>

<?php if (!empty($productName)) { ?>

    <h4><?= __('Product') ?></h4>

    <table>
        <tr>
            <th></th>
            <th><?= __('Product') ?></th>
            <th><?= __('Price') ?></th>
        </tr>
        <tr>
            <td>
                <img src="<?= $productImage ?>" alt="<?= $productName ?>">
            </td>
            <td>
                <p><?= $productName ?></p>
                <p><?= $productSku ?></p>
            </td>
            <td>
                <p><?= $productPrice ?></p>
            </td>
        </tr>
    </table>
<?php } ?>

<?php if (!empty($productWishlist)) { ?>

    <?php
        $wishlistProductsCollection = [];
        $singleProducts = explode(';',$productWishlist);
        foreach ($singleProducts as $product) {
            $formattedProduct = explode('|',$product);
            $wishlistProductsCollection[] = $formattedProduct;
        }
    ?>

    <h4><?= __('Products from wishlist') ?></h4>

    <table>
        <tr>
            <th></th>
            <th><?= __('Product') ?></th>
            <th><?= __('Price') ?></th>
        </tr>

        <?php foreach ($wishlistProductsCollection as $wishlistProduct) { ?>
            <tr>
                <td>
                    <img src="<?= $wishlistProduct[3] ?>" alt="<?= $wishlistProduct[0] ?>">
                </td>
                <td>
                    <p><?= $wishlistProduct[0] ?></p>
                    <p><?= $wishlistProduct[1] ?></p>
                </td>
                <td>
                    <p><?= $wishlistProduct[2] ?></p>
                </td>
            </tr>
        <?php } ?>

    </table>
<?php } ?>
