如何在产品页面OpenCart 2.3的三个选项中选择一个作为默认选项?

时间:2018-09-03 12:50:06

标签: opencart

我需要: 当买家查看我的网站产品并转到产品页面时,他看到一个选择的选项具有第一价格,我将其用于产品设置的“数据”中。 我做的事: 在OpenCart 2.3的产品页面(product.tpl)中,我无法为具有以下代码的产品选择默认选项价格:

<?php if ($key == 2) echo ('checked');?>

要插入:

<!--radio or new option Color-->
        <?php if ($option['type'] == 'radio' || $option['type'] == 'radio-color') { $num ++; ?>
        <div class="wrapper form-group7 display-block w-auto">
            <label class="title-options" for="input-option<?php echo $option['product_option_id']; ?>"><?php echo $option['name']; ?><?php if ($option['required']) : ?><span class="color-required">*</span><?php endif; ?></label>

          <?php
          foreach ($option['product_option_value'] as $option_value) {
                if ($option_value['image']) { $radio_class = 'options-swatch-texture'; } else {$radio_class = 'radio-list';}
           }
          ?>


            <ul class="options-swatch <?php echo $radio_class; ?>" id="input-option<?php echo $option['product_option_id']; ?>">
                <?php foreach ($option['product_option_value'] as $key => $option_value) { ?>
                <li>
                    <?php if ($option_value['image']) { ?>
                    <a>
                        <label>
                            <input class="display-n" type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" />
                            <img class="icon-color icon-color<?php echo $num; ?>" src="<?php echo $option_value['image']; ?>" title="<?php echo $option_value['name']; ?>
                        <?php if ($option_value['price']) { ?>(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)<?php } ?>" alt="<?php echo $option_value['name'] . ($option_value['price'] ? ' ' . $option_value['price_prefix'] . $option_value['price'] : ''); ?>" />
                        </label>
                    </a>
                    <?php } else { ?>
                    <label class="radio">
                        {*<?php if ($key == 2) echo ('checked');?>*}
                        <input type="radio" <?php if ($key == 2) echo ('checked');?> name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>"  /> <!--echo $option_value['product_option_value_id']; -->
                        <span class="outer"><span class="inner"></span></span><?php echo $option_value['name']; ?>


                    </label>
                    <?php } ?>
                </li>
                <?php } ?>
            </ul>
        </div>

        <script type="text/javascript">
            var iconcolor<?php echo $num; ?> = $(".icon-color<?php echo $num; ?>:not(.disable)");
            iconcolor<?php echo $num; ?>.click(function () {
                if ($(this).hasClass("selected")) iconcolor<?php echo $num; ?>.each(function () {
                    $(this).removeClass("selected")
                });
                else {
                    iconcolor<?php echo $num; ?>.each(function () {
                        $(this).removeClass("selected")
                    });
                    $(this).addClass("selected")
                }
            });
        </script>
        <?php } ?>
        <!--//radio or new option Color-->

问题在这里-看客户的情况

{**}选项1
{**}选项2
{*checked*}选项3

需要:

选项1
  选项2
*选项3

0 个答案:

没有答案