在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......

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.