Disabling Pop Up Images on Zen Cart Website’s Product Pages

Recently, we were brought in to disable the pop up to show larger images on the product page of a Zen Cart website. Looking around, we didn’t see information on doing this with more recent versions of Zen Cart. With the default template files of Zen Cart, there isn’t an option in the admin area to do that. Instead, you need to modify a template file.

If a template hasn’t been overridden, the file handling this is at /includes/templates/template_default/templates/tpl_modules_main_product_image.php

The relevant code is this:

    <a href="javascript:void(0);" onclick="openModal('imageModalPrimary')">
        <?php echo zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT); ?>
        <br>
<!--        <div class="imgLink center">--><?php //echo TEXT_CLICK_TO_ENLARGE; ?><!--</div>-->
    </a>

What that code does is to create a link that runs JavaScript code that surrounds the image. That would be this part of the code, “<a href=”javascript:void(0);” onclick=”openModal(‘imageModalPrimary’)”>” and “</a>”. When the image is clicked, the JavaScript code runs and the pop up appears.

The simplest way to change that is to comment out the lines like one line in the code already was. So it would look like this:

<!--    <a href="javascript:void(0);" onclick="openModal('imageModalPrimary')">-->
        <?php echo zen_image($products_image_medium, $products_name, MEDIUM_IMAGE_WIDTH, MEDIUM_IMAGE_HEIGHT); ?>
        <br>
<!--        <div class="imgLink center">--><?php //echo TEXT_CLICK_TO_ENLARGE; ?><!--</div>-->
<!--    </a>-->

You could also remove the code. There also is code above that in the file that loads the larger image, which you could also comment or remove.

Any changes you make to the default template files need to be reapplied when you do an upgrade of Zen Cart, if the template files is changed. Or you can use template overrides to handle the changes instead modifying default files.

If you need help handling something like this with your Zen Cart website, we are available to help.

Leave a Reply

Your email address will not be published.