Adding an image to a product option checkbox

You can add an image using the “image” option of the OpenCart option. Unfortunately this option only works as a radio button and once ticked can not be unticked.

To show the check box option image you need to add the following code to the product.tpl file under:

/catalog/view/theme/”your_theme”/template/product

Directly after:

        <?php if ($option['type'] == 'checkbox') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
          <?php foreach ($option['option_value'] as $option_value) { ?>

Add This:

<!-- Following was added by ME! to allow images on checkbox -->

<label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><img src="<?php echo $option_value['image']; ?>" alt="<?php echo $option_value['name'] . ($option_value['price'] ? ' ' . $option_value['price_prefix'] . $option_value['price'] : ''); ?>" align="middle"/></label>

<!-- Above was added by ME! to allow images on checkbox -->
Print Friendly, PDF & Email

More Like This


Categories


Open Cart Web Hosting
  • Post a comment