<?php
/**
 * Maho
 *
 * @category    design
 * @package     base_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
/**
 * One page checkout payment methods
 *
 * @var Mage_Checkout_Block_Onepage_Payment_Methods $this
 */

$methods = $this->getMethods();
$oneMethod = count($methods) <= 1;
?>

<?php if (empty($methods)): ?>
    <dt>
        <?= $this->__('No Payment Methods') ?>
    </dt>
<?php else: ?>
    <?php foreach ($methods as $_method): ?>
        <?php $_code = $_method->getCode(); ?>
        <dt id="dt_method_<?= $_code ?>">
            <?php if (!$oneMethod): ?>
                <input id="p_method_<?= $_code ?>" value="<?= $_code ?>" type="radio" name="payment[method]" title="<?= $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?= $_code ?>')"<?php if ($this->getSelectedMethodCode() == $_code): ?> checked="checked"<?php endif ?> class="radio" />
            <?php else: ?>
                <span class="no-display"><input id="p_method_<?= $_code ?>" value="<?= $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
                <?php $oneMethod = $_code; ?>
            <?php endif ?>
            <label for="p_method_<?= $_code ?>"><?= $this->escapeHtml($this->getMethodTitle($_method)) ?> <?= $this->getMethodLabelAfterHtml($_method) ?></label>
        </dt>
        <?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
            <dd id="dd_method_<?= $_code ?>">
                <?= $html ?>
            </dd>
        <?php endif ?>
    <?php endforeach ?>
<?php endif ?>
<?= $this->getChildChildHtml('additional') ?>
<script type="text/javascript">
<?= $this->getChildChildHtml('scripts') ?>
payment.init();
<?php if (is_string($oneMethod)): ?>
payment.switchMethod('<?= $oneMethod ?>');
<?php endif ?>
</script>
