选项复选框作为opencart中的下拉列表

时间:2018-08-05 09:46:29

标签: javascript php css opencart

此问题与Opencart 2.3.x选项有关。我有很多选择,有很多选择,其中大多数是多选选项。如果我将其作为复选框进行,它将是一长串的选择,这非常复杂。是否可以将复选框选项设置为下拉菜单?如果我理解正确,则必须编辑目录/视图/主题/ ...主题... / template / product / product.tpl

如何为复选框下拉菜单编辑此文件?

    <?php // Product Options ---------------------------------------------- ?>

<?php $tbData->slotStart('product/product.product_options', array('data' => $data)); ?>
<?php if ($options || $recurrings): ?>
<?php if ($tbData['system.product_options']['block_title']): ?>
<div class="panel-heading">
  <h2 class="panel-title"><?php echo $text_option; ?></h2>
</div>
<?php endif; ?>

<?php $tbData->slotFilter('product/product_options.filter', $options, array('data' => $data)); ?>
<div class="options panel-body form-horizontal">

  <?php foreach ($options as $option) { ?>

  <?php // SELECT  ?>
  <?php if ($option['type'] == 'select') { ?>
  <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?>">
    <label class="control-label" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?></label>
    <div class="col-sm-9">
      <select name="option[<?php echo $option['product_option_id']; ?>]" id="input-option<?php echo $option['product_option_id']; ?>" class="form-control">
        <option value=""><?php echo $text_select; ?></option>
        <?php foreach ($option['product_option_value'] as $option_value) { ?>
        <option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
          <?php if ($option_value['price']) { ?>
          (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
          <?php } ?>
        </option>
        <?php } ?>
      </select>
    </div>
  </div>
  <?php } ?>

  <?php // RADIO  ?>
  <?php if ($option['type'] == 'radio') { ?>
  <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?><?php if (isset($option['tb_css_classes']) && !empty($option['tb_css_classes'])) echo' tb_' . $option['tb_css_classes']; ?>">
    <?php if ($tbData->OcVersionGte('2.3.0.0') && !empty($option['tb_css_classes']) && $option['tb_css_classes'] == 'style_2' && isset($option['image_width'])): ?>
    <style scoped>
    #input-option<?php echo $option['product_option_id']; ?> img {
      width: <?php echo $option['image_width']; ?>px;
      height: <?php echo $option['image_height']; ?>px;
    }
    </style>
    <?php endif; ?>
    <label class="control-label"><?php echo $option['name']; ?></label>
    <div class="col-sm-9">
      <div id="input-option<?php echo $option['product_option_id']; ?>">
        <?php foreach ($option['product_option_value'] as $option_value) { ?>
        <div class="radio<?php if (!empty($option_value['image']) && $tbData->OcVersionGte('2.3.0.0')): ?> image<?php endif; ?>">
          <label<?php if (isset($option['tb_css_classes']) && !empty($option['tb_css_classes']) && $option['tb_css_classes'] == 'style_2'): ?> class="tb_bg_str_2 tb_bg_hover_str_3"<?php endif; ?><?php if ($option_value['price']) { ?> title="<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>"<?php } ?>>
            <input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" />
            <?php if ($tbData->OcVersionGte('2.3.0.0')): ?>
            <?php if ($option_value['image']) { ?>
            <img src="<?php echo $option_value['image']; ?>" alt="<?php echo $option_value['name'] . ($option_value['price'] ? ' ' . $option_value['price_prefix'] . $option_value['price'] : ''); ?>" class="img-thumbnail" /> 
            <?php } ?>
            <?php endif; ?>
            <span>
              <?php echo $option_value['name']; ?>
              <?php if ($option_value['price']) { ?><span>
              (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
              </span><?php } ?>
            </span>
          </label>
        </div>
        <?php } ?>
      </div>
    </div>
  </div>
  <?php } ?>

  <?php // CHECKBOX  ?>
  <?php if ($option['type'] == 'checkbox') { ?>
  <div class="form-group<?php echo ($option['required'] ? ' required' : ''); ?><?php if (isset($option['tb_css_classes']) && !empty($option['tb_css_classes'])) echo' tb_' . $option['tb_css_classes']; ?>">
    <?php if ($tbData->OcVersionGte('2.2.0.0') && !empty($option['tb_css_classes']) && $option['tb_css_classes'] == 'style_2' && isset($option['image_width'])): ?>
    <style scoped>
    #input-option<?php echo $option['product_option_id']; ?> img {
      width: <?php echo $option['image_width']; ?>px;
      height: <?php echo $option['image_height']; ?>px;
    }
    </style>
    <?php endif; ?>
    <label class="control-label"><?php echo $option['name']; ?></label>
    <div class="col-sm-9">
      <div id="input-option<?php echo $option['product_option_id']; ?>">
        <?php foreach ($option['product_option_value'] as $option_value) { ?>
        <?php if ($tbData->OcVersionGte('2.2.0.0')): ?>
        <div class="checkbox<?php if ($option_value['image']) echo ' image'; ?>">
        <?php else: ?>
        <div class="checkbox<?php if (!empty($option_value['image']) && $tbData->OcVersionGte('2.2.0.0')): ?> image<?php endif; ?>">
        <?php endif; ?>
          <label<?php if (isset($option['tb_css_classes']) && !empty($option['tb_css_classes']) && $option['tb_css_classes'] == 'style_2'): ?> class="tb_bg_str_2 tb_bg_hover_str_3"<?php endif; ?><?php if ($option_value['price']) { ?> title="<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>"<?php } ?>>
            <input type="checkbox" name="option[<?php echo $option['product_option_id']; ?>][]" value="<?php echo $option_value['product_option_value_id']; ?>" />
            <?php if ($tbData->OcVersionGte('2.2.0.0')): ?>
            <?php if ($option_value['image']) { ?>
            <img src="<?php echo $option_value['image']; ?>" alt="<?php echo $option_value['name'] . ($option_value['price'] ? ' ' . $option_value['price_prefix'] . $option_value['price'] : ''); ?>" class="img-thumbnail" />
            <?php } ?>
            <?php endif; ?>
            <span>
              <?php echo $option_value['name']; ?>
              <?php if ($option_value['price']) { ?><span>
              (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
              </span><?php } ?>
            </span>
          </label>
        </div>
        <?php } ?>
      </div>
    </div>
  </div>
  <?php } ?>

请帮助!我花了很多时间来查找有关此问题的信息,但未成功。谢谢!!

0 个答案:

没有答案