<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var \Magento\Multishipping\Block\Checkout\Results $block */

$orderIds = $block->getOrderIds();
?>
<div class="multicheckout results">
    <p class="block-content">
        <?php if (!empty($orderIds)) : ?>
            <?= $block->escapeHtml(__('Not all items were included.')); ?>
        <?php endif; ?>
        <?= $block->escapeHtml(__('For details, see')); ?>
        <a href="#failed"><?= $block->escapeHtml(__('Failed to Order')); ?></a>
        <?= $block->escapeHtml(__('section below')); ?>
    </p>
    <?php if (!empty($orderIds)) : ?>
    <p class="block-content">
        <?= $block->escapeHtml(__('For successfully ordered items, you\'ll receive a confirmation email '.
            'including order numbers, tracking information, and more details.')); ?>
    </p>
    <div class="orders-succeed">
        <h3 class="subtitle"><?= $block->escapeHtml(__('Successfully Ordered')); ?></h3>
        <ul class="orders-list">
            <?php foreach ($orderIds as $orderId => $incrementId) : ?>
                <li class="shipping-list">
                    <div class="order-id"><a href="<?= $block->escapeUrl($block->getViewOrderUrl($orderId)); ?>">
                    <?= $block->escapeHtml($incrementId); ?></a></div>
                    <?php $shippingAddress = $block->getOrderShippingAddress($orderId); ?>
                    <div class="shipping-item">
                        <?php if ($shippingAddress) : ?>
                        <span class="shipping-label"><?= $block->escapeHtml(__('Ship to:')); ?></span>
                        <span class="shipping-address">
                            <?= $block->escapeHtml($block->formatOrderShippingAddress($shippingAddress)); ?>
                        </span>
                        <?php else : ?>
                            <span class="shipping-address">
                                <?= $block->escapeHtml(__('No shipping required.')); ?>
                            </span>
                        <?php endif; ?>
                    </div>
                </li>
            <?php endforeach; ?>
        </ul>
    </div>
    <?php endif; ?>
    <div class="orders-failed">
        <h3 class="subtitle"><a name="failed"><?= $block->escapeHtml(__('Failed to Order')); ?></a></h3>
        <div class="message message-error error">
            <div>
                <?= $block->escapeHtml(__('To purchase these items: Return to the')); ?>
                <a href="<?= $block->escapeUrl($block->getUrl('*/*/overview')) ?>">
                    <?= $block->escapeHtml(__('Review page in Checkout')); ?></a>,
                <?= $block->escapeHtml(__('resolve any errors, and place a new order.'))?>
            </div>
        </div>
        <?php $failedAddresses = $block->getFailedAddresses() ?>
        <?php if (!empty($failedAddresses)) : ?>
            <ol class="orders-list">
                <?php foreach ($failedAddresses as $address) : ?>
                <li class="shipping-list">
                    <dl class="shipping-item">
                        <dt class="shipping-block">
                            <?php if ($block->isShippingAddress($address)) : ?>
                            <span class="shipping-label"><?= $block->escapeHtml(__('Ship to:')); ?></span>
                            <span class="shipping-address">
                                <?= $block->escapeHtml($block->formatQuoteShippingAddress($address)); ?>
                            </span>
                            <?php else : ?>
                            <span class="shipping-address">
                                <?= $block->escapeHtml(__('No shipping required.')); ?>
                            </span>
                            <?php endif; ?>
                        </dt>
                        <dd class="error-block">
                            <span class="error-label"><?= $block->escapeHtml(__('Error:')); ?></span>
                            <span class="error-description">
                                <?= /* @noEscape */ $block->getAddressError($address); ?>
                            </span>
                        </dd>
                    </dl>
                </li>
                <?php endforeach; ?>
            </ol>
        <?php endif;?>
    </div>
</div>
