douchongbang6011 2012-12-04 06:02
浏览 47

在Opencart的选项框中删除价格

Hi i am in new in opencart. I have code in product.tpl. i want remove the "price" in the option box selection.... If i remove the "price" in option box, it affect in price calculation i.e., finalpricevalue in header.tpl

I want solution

  1. hide the "price" in the option box (OR)
  2. Change the colour of "price" in the option box (OR)
  3. remove the "price" in product.tpl and assign value to "finalpricevalue" in header.tpl

product.tpl---->

<select name="option[<?php echo $option['product_option_id']; ?>]" width="300"style="width:200px">
<option value=""><?php echo $text_select; ?></option>

<?php foreach ($option['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>

header.tpl----->

var position1 = newPriceValue.indexOf("(");
var position2 = newPriceValue.indexOf(")");
position1 = position1+3;
var **finalPriceValue** = newPriceValue.substring(position1, position2);
var txt = newPriceValue;
txt = txt.replace(/,/g, '');
array=txt.match(/(?!$)\d+(\.\d+)/g);

Please help me......

  • 写回答

1条回答 默认 最新

  • duanhuau567787 2012-12-05 00:21
    关注

    In product.tpl there are several instances of $option_value['price'] correlating to different types of options you can have on a product. First make a copy of product.tpl for a backup then to make the price "disappear" search product.tpl for each instance of:

        <?php if ($option_value['price']) { ?>
        (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
        <?php } ?>
    

    and enclose it with a html comment like this:

        <!--
        <?php if ($option_value['price']) { ?>
        (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
        <?php } ?>  
        -->   
    

    That shouldn't effect the header total which is what I assume you mean by:

    If i remove the "price" in option box, it affect in price calculation

    1. To change the color of the price; find the same code blocks and make it something like this:

      <?php if ($option_value['price']) { ?>
      <span class="price_color">(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)</span>
      <?php } ?>
      

    Then make a backup copy of /catalog/view/theme/your_theme/stylesheet/stylesheet.css and add:

        .price_color {color: #000000} 
    

    or whatever color you want it to be. Just enclosing it in a span for styling. There may be better ways to do what you're trying to do. You might put the styling in a new css so its not overwritten when updating the template if it's not your own.

    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等