Vipin Kr. Singh
Vipin Kr. Singh

Reputation: 672

Developing new Option type for Product in OpenCart

I want to code a new option type for products in OpenCart, for example lets say: there is already an option for checkbox (Catelog->Options->insert and select checkbox from 'Type' Dropdown). The default checkbox has three entry fields 1. Option Value Name' 2. Image 3. Sort Order. Now if I want to create a new checkbox with different entry options like a checkbox with a category or product selection option. How to deal with such a situation. At Opencart's Official documentation http://docs.opencart.com/display/opencart/Developer+guide : that explains only how to create a module which has its own individual layout(.tpl) but in my case I don't need to provide additional layout in admin area for this sort of module, I just need to hookup my code in such a way that it displays newly added option with existing options listed under Catelog->Options->insert and 'Type'. Any help or clue will be appreciated from you guys. Thanks in advance.

Upvotes: 0

Views: 4785

Answers (1)

Sankar V
Sankar V

Reputation: 4128

Goto admin/view/template/catalog/option_form.tpl

 <tr>
        <td><?php echo $entry_type; ?></td>
        <td><select name="type">
            <optgroup label="<?php echo $text_choose; ?>">
            <?php if ($type == 'select') { ?>
            <option value="select" selected="selected"><?php echo $text_select; ?></option>
            <?php } else { ?>
            <option value="select"><?php echo $text_select; ?></option>
            <?php } ?>
            <?php if ($type == 'radio') { ?>
            <option value="radio" selected="selected"><?php echo $text_radio; ?></option>
            <?php } else { ?>
            <option value="radio"><?php echo $text_radio; ?></option>
            <?php } ?>
            <?php if ($type == 'checkbox') { ?>
            <option value="checkbox" selected="selected"><?php echo $text_checkbox; ?></option>
            <?php } else { ?>
            <option value="checkbox"><?php echo $text_checkbox; ?></option>
            <?php } ?>
            <?php if ($type == 'image') { ?>
            <option value="image" selected="selected"><?php echo $text_image; ?></option>
            <?php } else { ?>
            <option value="image"><?php echo $text_image; ?></option>
            <?php } ?>
            </optgroup>
            <optgroup label="<?php echo $text_input; ?>">
            <?php if ($type == 'text') { ?>
            <option value="text" selected="selected"><?php echo $text_text; ?></option>
            <?php } else { ?>
            <option value="text"><?php echo $text_text; ?></option>
            <?php } ?>
            <?php if ($type == 'textarea') { ?>
            <option value="textarea" selected="selected"><?php echo $text_textarea; ?></option>
            <?php } else { ?>
            <option value="textarea"><?php echo $text_textarea; ?></option>
            <?php } ?>
            </optgroup>
            <optgroup label="<?php echo $text_file; ?>">
            <?php if ($type == 'file') { ?>
            <option value="file" selected="selected"><?php echo $text_file; ?></option>
            <?php } else { ?>
            <option value="file"><?php echo $text_file; ?></option>
            <?php } ?>
            </optgroup>
            <optgroup label="<?php echo $text_date; ?>">
            <?php if ($type == 'date') { ?>
            <option value="date" selected="selected"><?php echo $text_date; ?></option>
            <?php } else { ?>
            <option value="date"><?php echo $text_date; ?></option>
            <?php } ?>
            <?php if ($type == 'time') { ?>
            <option value="time" selected="selected"><?php echo $text_time; ?></option>
            <?php } else { ?>
            <option value="time"><?php echo $text_time; ?></option>
            <?php } ?>
            <?php if ($type == 'datetime') { ?>
            <option value="datetime" selected="selected"><?php echo $text_datetime; ?></option>
            <?php } else { ?>
            <option value="datetime"><?php echo $text_datetime; ?></option>
            <?php } ?>
            </optgroup>
          </select></td>
      </tr>

You can see that the option types are hardcoded. Just edit it or use vqmod(Opencart Vqmod Tutorial) to add your new option type.

Have a nice day!!

Upvotes: 2

Related Questions