<?php
/**
 * Maho
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
 * @copyright   Copyright (c) 2021-2023 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
/**
 * Shopping cart template
 *
 * @var Mage_Checkout_Block_Cart $this
 */
?>
<div class="cart">
    <div class="page-title title-buttons">
        <h1><?= $this->__('Shopping Cart') ?></h1>
        <?php if(!$this->hasError()): ?>
        <ul class="checkout-types">
        <?php foreach ($this->getMethods('top_methods') as $method): ?>
            <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
            <li><?= $methodHtml ?></li>
            <?php endif ?>
        <?php endforeach ?>
        </ul>
        <?php endif ?>
    </div>
    <?= $this->getMessagesBlock()->toHtml() ?>
    <?= $this->getChildHtml('form_before') ?>
    <form action="<?= $this->getFormActionUrl() ?>" method="post">
        <?= $this->getBlockHtml('formkey') ?>
        <fieldset>
            <table id="shopping-cart-table" class="data-table cart-table">
                <col width="1" />
                <col />
                <col width="1" />
            <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
                <col width="1" />
            <?php endif ?>
            <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
                <col width="1" />
            <?php endif ?>
            <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
                <col width="1" />
            <?php endif ?>
                <col width="1" />
            <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
                <col width="1" />
            <?php endif ?>
            <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
                <col width="1" />
            <?php endif ?>
                <col width="1" />

            <?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>
                <thead>
                    <tr>
                        <th rowspan="<?= $mergedCells ?>">&nbsp;</th>
                        <th rowspan="<?= $mergedCells ?>"><span class="nobr"><?= $this->__('Product Name') ?></span></th>
                        <th rowspan="<?= $mergedCells ?>"></th>
                        <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
                        <th rowspan="<?= $mergedCells ?>" class="a-center"><span class="nobr"><?= $this->__('Move to Wishlist') ?></span></th>
                        <?php endif ?>
                        <th class="a-center" colspan="<?= $mergedCells ?>"><span class="nobr"><?= $this->__('Unit Price') ?></span></th>
                        <th rowspan="<?= $mergedCells ?>" class="a-center"><?= $this->__('Qty') ?></th>
                        <th class="a-center" colspan="<?= $mergedCells ?>"><?= $this->__('Subtotal') ?></th>
                        <th rowspan="<?= $mergedCells ?>" class="a-center">&nbsp;</th>
                    </tr>
                    <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
                    <tr>
                        <th class="a-right"><?= $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
                        <th><?= $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
                        <th class="a-right"><?= $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
                        <th><?= $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
                    </tr>
                    <?php endif ?>
                </thead>
                <tfoot>
                    <tr>
                        <td colspan="50" class="a-right">
                            <?php if($this->getContinueShoppingUrl()): ?>
                                <button type="button" title="<?= Mage::helper('core')->quoteEscape($this->__('Continue Shopping')) ?>" class="button btn-continue" onclick="setLocation('<?= Mage::helper('core')->quoteEscape($this->getContinueShoppingUrl()) ?>')"><?= $this->__('Continue Shopping') ?></button>
                            <?php endif ?>
                            <button type="submit" name="update_cart_action"  value="update_qty" title="<?= Mage::helper('core')->quoteEscape($this->__('Update Shopping Cart')) ?>" class="button btn-update"><?= $this->__('Update Shopping Cart') ?></button>
                            <button type="submit" name="update_cart_action" value="empty_cart" title="<?= Mage::helper('core')->quoteEscape($this->__('Clear Shopping Cart')) ?>" class="button btn-empty" id="empty_cart_button"><?= $this->__('Clear Shopping Cart') ?></button>
                        </td>
                    </tr>
                </tfoot>
                <tbody>
                <?php foreach($this->getItems() as $_item): ?>
                    <?= $this->getItemHtml($_item) ?>
                <?php endforeach ?>
                </tbody>
            </table>
        </fieldset>
    </form>
    <div class="cart-collaterals">
        <div class="col2-set">
            <div class="col-1">
                <?= $this->getChildHtml('crosssell') ?>
            </div>
            <div class="col-2">
                <?php /* Extensions placeholder */ ?>
                <?= $this->getChildHtml('checkout.cart.extra') ?>
                <?= $this->getChildHtml('coupon') ?>
                <?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>
            </div>
        </div>
        <div class="totals">
            <?= $this->getChildHtml('totals') ?>
            <?php if(!$this->hasError()): ?>
            <ul class="checkout-types">
            <?php foreach ($this->getMethods('methods') as $method): ?>
                <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
                <li><?= $methodHtml ?></li>
                <?php endif ?>
            <?php endforeach ?>
            </ul>
            <?php endif ?>
        </div>
    </div>
</div>
