Is there a way to edit the default custom option template on frontend?

Currently the following template file:


Load the custom options by <?php echo $this->getValuesHtml() ?>

But I want to change somethings on the loaded HTML. For example I want to display also the €0,00 price or the word "Default" when the option does not increase the price. I also want to display the minus prices, when a option decrease the price. And I want to display the price excluding VAT only.

How can I achieve this? What is the loaded file, that loads the ValuesHtml?

  1. If you want to update the select template, you have to add what you want on it in your theme files, so Magento get it from your theme first then the default then the base as the Magento theme fallback system.

  2. Now if you want to update the data that contains this select.phtml like $this->getValuesHtml()(what you are looking for), you have to rewrite the Select.php in your local codePool from : app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php getValuesHtml()

  • Thanks for your reply. But in that Select.php I can't find anything about the pricing for example. I want to edit the following HTML for example: <span class="price-notice">+<span class="price">€&nbsp;20,66</span> (+<span class="price">€&nbsp;25,00</span> Incl. VAT)</span> and give the in and ex vat their own class, to hide then using css. – JGeer Jan 9 '18 at 7:49
  • I think that you're looking for getPrice() that can be found in app/code/core/Mage/Catalog/Block/Product/View/Price.php – PЯINCƏ Jan 9 '18 at 9:19
  • Thanks! I can also not find that specific HTML inside that file. That only shows return $product->getFormatedPrice(); – JGeer Jan 9 '18 at 9:29
  • Look app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php – PЯINCƏ Jan 9 '18 at 9:35
  • Thanks a lot! That's exactly the file I was looking for. Do you also know the file that is loading the input radio and label of the option? – JGeer Jan 9 '18 at 9:49

$this->getValuesHtml() is inherited from app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php.

Note: In many cases the template path is a hint to the relevant block path already (if you take a look after design/frontend/theme/theme/template what remains is catalog/product/view/options/type/select which is basically the Catalog module in app/code/core and since you're looking for a Block the rest is quite easy to follow based on the template path again). This however is not always the case and is just meant to be a quick hint for all the lazy ones out there ;).

For getting a better idea what block is underlying your template please enable the block name hints from backend.

You can find them at System > Configuration > ADVANCED > Developer - now change to your desired website or store view in the upper left scope drop down - and then enable Template Path Hints (which gives you the path to the template file [mandatory for the next option to take effect]) and Add Block Names to Hints (which gives you the relevant block class for the same).

Often Magento core developers even left comments in the template files specifying what $this is. This comment is present in select.phtml as well:

<?php /* @var $this Mage_Catalog_Block_Product_View_Options_Type_Select */ ?>

Also, the relevant layout xml can give you an idea about what template and block files are related to each other, but that might go to far now - still for the record, catalog.xml is stating an action, inheriting the relevant block and template file:

<action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>catalog/product/view/options/type/select.phtml</template></action>

So in your case all these would give you Mage_Catalog_Block_Product_View_Options_Type_Select or in other words as a file path. app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php

I assume you're aware about it already but one common, additional note is to be made here again: as always, do NOT modify this file directly.

Either create a copy under app/code/local/Mage/Catalog/Block/Product/View/Options/Type/Select.php or, even better, create your own custom module and rewrite the block from there to be even more future-proof.

  • Many many thanks for your reply! When looking at the View/Options/Type/Select.php file, there I can not find the prices ex and including VAT. Do you know a solution to only display the prices ex VAT of the custom option? If we can captire it inside a <span> for example, that whould be also a fine solution, by hiding it using css. – JGeer Jan 8 '18 at 21:31
  • I'm not quite sure where you're aiming with this to be honest. As a general note first of all, the template for (incl and excl) prices is app/design/frontend/theme/theme/template/catalog/product/price.phtml (there are some other ways though). Whether or not prices will be displayed with or without tax however primarily will be specified in backend (System > Configuration > SALES > Tax). So, to get you correctly, you got here let's say both "display w/ and w/o tax" selected but in the custom option you'd like to show the price w/o tax only? May I ask you to re-phrase your original question? – Christoph Farnleitner Jan 8 '18 at 21:57
  • Thanks for your reply. I am looking for the default HTML that display the prices of the custom options. We already use the TAX option in the backend, but for other places on the website we need to display both. But in this custom options we want to dislay only the price ex VAT. I am looking for this HTML: <span class="price-notice">+<span class="price">€&nbsp;20,66</span> (+<span class="price">€&nbsp;25,00</span> Incl. VAT)</span> – JGeer Jan 9 '18 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.