<?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
/**
 * Template for displaying product price at catalog and sidebars
 *
 * @var Mage_Catalog_Block_Product_Price $this
 */
?>
<?php
    /** @var Mage_Catalog_Model_Product $_product */
    $_product = $this->getProduct();
    $_msrpPrice = "";
?>
    <div class="price-box map-info">
    <?php $_price = $this->helper('tax')->getPrice($_product, $_product->getMsrp()) ?>
        <?php if ($_product->getMsrp()): ?>
            <?php $_msrpPrice = $this->helper('core')->currency($_product->getMsrp(),true,true) ?>
            <span class="old-price" id="product-price-<?= $_product->getId() ?><?= $this->getIdSuffix() ?>"><?= $_msrpPrice ?></span>
        <?php endif ?>
        <?php $helpLinkId = 'msrp-click-' . $_product->getId() . $this->helper('core')->getRandomString(20); ?>
        <a href="#" class="map-link" id="<?php echo($helpLinkId);?>"><?= $this->__('Click for price') ?></a>
        <script type="text/javascript">
            <?php if ($this->helper('catalog')->isShowPriceOnGesture($_product)): ?>
                var productLink = {
                    url: "<?= $_product->isSalable() ? $this->getAddToCartUrlCustom($_product, [], false) : '' ?>",
                    notUseForm: true
                };
                var newLink = Catalog.Map.addHelpLink(
                        '<?= $helpLinkId ?>',
                        "<?= $this->escapeHtml($_product->getName()) ?>",
                        <?= $this->getRealPriceJs($_product) ?>,
                        '<?= $_msrpPrice ?>',
                        productLink
                );
                newLink.product_id = '<?= $_product->getId() ?>';
            <?php else: ?>
                Catalog.Map.addHelpLink(
                        '<?= $helpLinkId ?>',
                        null,
                        null,
                        null,
                        "<?= $_product->getProductUrl() ?>"
                );
            <?php endif ?>

        </script>
    </div>
