<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2024 The OpenMage Contributors (https://openmage.org)
 * @copyright   Copyright (c) 2024 Maho (https://mahocommerce.com)
 * @license     https://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Cart cross sell items template
 *
 * @see Mage_Checkout_Block_Cart_Crosssell
 * @var Mage_Checkout_Block_Cart_Crosssell $this
 */
?>
<?php if($this->getItemCount()): ?>
<?php $_params = $this->escapeHtml(json_encode(['form_key' => $this->getFormKey()])); ?>
<div class="crosssell">
    <h2><?= $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
    <ul id="crosssell-products-list" class="products-grid products-grid--max-3-col">
    <?php foreach ($this->getItems() as $_item): ?>
        <li class="item">
            <div class="product-info">
                <a class="product-image" href="<?= $_item->getProductUrl() ?>" title="<?= $this->escapeHtml($_item->getName()) ?>">
                    <img src="<?= $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(210) ?>" alt="<?= $this->escapeHtml($_item->getName()) ?>" />
                </a>
                <h3 class="product-name"><a href="<?= $_item->getProductUrl() ?>"><?= $this->escapeHtml($_item->getName()) ?></a></h3>
                <?= $this->getPriceHtml($_item, true) ?>
                <div class="actions">
                    <button type="button"
                            title="<?= Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>"
                            class="button btn-cart"
                            onclick="customFormSubmit(
                                    '<?= $this->getAddToCartUrlCustom($_item, [], false) ?>',
                                    '<?= $_params ?>',
                                    'post')">
                        <?= $this->__('Add to Cart') ?>
                    </button>
                    <ul class="add-to-links">
                        <?php if ($this->helper('wishlist')->isAllow()) : ?>
                            <?php $_wishlistUrl = $this->getAddToWishlistUrlCustom($_item, false); ?>
                            <li>
                                <a href="#"
                                   data-url="<?= $_wishlistUrl ?>"
                                   data-params="<?= $_params ?>"
                                   class="link-wishlist"
                                   onclick="customFormSubmit('<?= $_wishlistUrl ?>', '<?= $_params ?>', 'post')">
                                    <?= $this->__('Add to Wishlist') ?>
                                </a>
                            </li>
                        <?php endif ?>
                        <?php if ($_compareUrl = $this->getAddToCompareUrlCustom($_item, false)) : ?>
                            <li>
                                <span class="separator">|</span>
                                <a href="#"
                                   class="link-compare"
                                   onclick="customFormSubmit('<?= $_compareUrl ?>', '<?= $_params ?>', 'post')">
                                    <?= $this->__('Add to Compare') ?>
                                </a>
                            </li>
                        <?php endif ?>
                    </ul>
                </div>
            </div>
        </li>
    <?php endforeach ?>
    </ul>
</div>
<?php endif ?>
