<?php
/**
 * Maho
 *
 * @category    design
 * @package     rwd_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
 */
?>
<?php $_priceDisplay = ($this->helper('tax')->displayCartBothPrices()) ? 'display-both-prices' : 'display-single-price'; ?>
<div class="cart <?= $_priceDisplay ?>">
    <div class="page-title title-buttons">
        <h1><?= $this->__('Shopping Cart') ?></h1>
        <?php if(!$this->hasError()): ?>
        <ul class="checkout-types top">
        <?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') ?>
        <table id="shopping-cart-table" class="cart-table data-table">
            <col width="1" />
            <col width="1" />
            <col width="1" />
            <col width="1" />
            <col width="1" />
            <col width="1" />
            <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
            <col width="1" />
            <col width="1" />
            <?php endif ?>

        <?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>
            <thead>
                <tr>
                    <th rowspan="<?= $mergedCells ?>"><span class="nobr"><?= $this->__('Product') ?></span></th>

                    <th rowspan="<?= $mergedCells ?>">&nbsp;</th>

                    <th class="a-center cart-price-head" colspan="<?= $mergedCells ?>">
                        <span class="nobr"><?= $this->__('Price') ?></span>
                    </th>

                    <th rowspan="<?= $mergedCells ?>" class="a-center">
                        <?= $this->__('Qty') ?>
                        <?php /* if ($this->helper('wishlist')->isAllowInCart()) : ?>
                            <span class="nobr"><?= $this->__('Move to Wishlist') ?></span>
                        <?php endif */ ?>
                    </th>

                    <th class="a-center cart-total-head" colspan="<?= $mergedCells ?>">
                        <?= $this->__('Subtotal') ?>
                    </th>

                    <th class="a-center" rowspan="<?= $mergedCells ?>">&nbsp;</th>
                </tr>
                <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
                <tr>
                    <th class="a-center cart-price-head"><?= $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
                    <th class="a-center cart-price-head"><?= $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
                    <th class="a-center cart-total-head"><?= $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
                    <th class="a-center cart-total-head"><?= $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
                </tr>
                <?php endif ?>
            </thead>
            <tfoot>
                <tr>
                    <td colspan="50" class="a-right cart-footer-actions">

                        <!-- Make this button the first responder rather than empty cart -->
                        <button type="submit" style="visibility:hidden;" data-cart-item-update name="update_cart_action" value="update_qty" title="<?= $this->quoteEscape($this->__('Update Shopping Cart')) ?>" class="button2 btn-update"><?= $this->__('Update Shopping Cart') ?></button>

                        <button type="submit" name="update_cart_action" data-cart-empty value="empty_cart" title="<?= $this->quoteEscape($this->__('Empty Cart')) ?>" class="button2 btn-empty" id="empty_cart_button"><?= $this->__('Empty Cart') ?></button>

                        <button type="submit" name="update_cart_action" data-cart-item-update value="update_qty" title="<?= $this->quoteEscape($this->__('Update Shopping Cart')) ?>" class="button2 btn-update"><?= $this->__('Update Shopping Cart') ?></button>

                        <span class="or">-<?= $this->__('or') ?>-</span>

                        <?php if ($this->getContinueShoppingUrl()): ?>
                            <button type="button" title="<?= $this->quoteEscape($this->__('Continue Shopping')) ?>" class="button2 btn-continue" onclick="setLocation('<?= Mage::helper('core')->quoteEscape($this->getContinueShoppingUrl()) ?>')"><?= $this->__('Continue Shopping') ?></button>
                        <?php endif ?>
                    </td>
                </tr>
            </tfoot>
            <tbody>
            <?php foreach($this->getItems() as $_item): ?>
                <?= $this->getItemHtml($_item) ?>
            <?php endforeach ?>
            </tbody>
        </table>
    </form>

    <?= $this->getChildHtml('shopping.cart.table.after') ?>
    <div class="cart-forms">
        <?php /* Extensions placeholder */ ?>
        <?= $this->getChildHtml('checkout_cart_widget') ?>
        <?= $this->getChildHtml('coupon') ?>
        <?= $this->getChildHtml('checkout.cart.extra') ?>
        <?php if (!$this->getIsVirtual()): echo $this->getChildHtml('shipping'); endif; ?>
    </div>
    <div class="cart-totals-wrapper">
        <div class="cart-totals">
            <?= $this->getChildHtml('totals') ?>
            <?php if(!$this->hasError()): ?>
            <ul class="checkout-types bottom">
            <?php foreach ($this->getMethods('methods') as $method): ?>
                <?php if ($methodHtml = $this->getMethodHtml($method)): ?>
                <li class="method-<?= preg_replace("/[^_a-zA-Z0-9-]/", '-', $method) ?>"><?= $methodHtml ?></li>
                <?php endif ?>
            <?php endforeach ?>
            </ul>
            <?php endif ?>
        </div>
    </div>
    <?= $this->getChildHtml('crosssell') ?>
</div>
