So I'm trying to merge two solutions together to form one.. I've been using the code from this answer to remove the "(Incl. Tax)" from the product page option selector for configurable products, and it works well. As shown in the linked answer, in app/design/frontend/rwd/myTheme/template/catalog/product/view/type/configurable.phtml i've changed the line
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $this->getJsonConfig(); ?>);
</script>
to the following:
<?php // get current drop down string
$currentstring = $this->getJsonConfig();
// create new string with true set to false using str_replace function (string replace)
$newstring = str_replace( '"showBothPrices":true,"','"showBothPrices":false,"', $currentstring );?>
<!-- render dropdown but with new var ($newstring) -->
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $newstring ?>);
</script>
This has the desired result of hiding the (Incl. tax) and makes me happy.
Later, I was asked if we could change the text in the select box from reading "Choose an option" to the name of the option or "Select (option name):"
I found the following answer which works perfectly - it replaces the complete contents of the same file with
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl>
<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<?php $chooseText = $this->__('Select %s', $_attribute->getLabel()); ?>
<select data-choose-text="<?php echo $chooseText; ?>" name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $chooseText; ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">
Product.ConfigDefaultText = new Class.create(Product.Config, {
fillSelect: function($super, element) {
$super(element);
var chooseDefaultText = element.getAttribute('data-choose-text');
$(element).options[0] = new Option(chooseDefaultText, '');
}
});
var spConfig = new Product.ConfigDefaultText(<?php echo $this->getJsonConfig() ?>);
</script>
Now this works great, we can set the option labels to anything we like, but in the process our "(Incl. tax)" returned to ruin my day.
I'm looking for someone to show me how i can merge these two bits of code and make them play nicely together so I can have both custom product option text and prevent the "(Incl. tax)" string from appearing.
Any help most appreciated.