I would like to show a message when user select any specific custom option in Magento 1.9.

I have two checkbox options: 'disposal' and 'installation'.

Current Issue

At the moment I can only show the message based on the headline title of the custom option, which is 'Delivery Options' (please see current code below).

Desired Result

If the custom option states 'disposal' I would like the message 'please disconnect device' to appear underneath. If the custom option states 'installation' I would like the message 'please connect device' to appear underneath.

select.phtml code requiring edit/update

    <?php if ($_option->getTitle() == 'Delivery Options')
    echo '<p>Please disconnect device for disposal.
    <br>Please connect device for installation.</p>' ?>

select.phtml code in full

<?php /* @var $this Mage_Catalog_Block_Product_View_Options_Type_Select */ ?>
<?php $_option = $this->getOption() ?>
<dt><label<?php if ($_option->getIsRequire()) echo ' class="required"' ?>><?php if ($_option->getIsRequire()) echo '<em>*</em>' ?><?php echo  $this->escapeHtml($_option->getTitle()) ?></label></dt>
<dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
    <div class="input-box">
        <?php echo $this->getValuesHtml() ?>
        <?php if ($_option->getTitle() == 'Delivery Options')
        echo '<p>Please ensure device is disconnected and empty prior to disposal collection.<br>Please ensure you have the correct fittings in place for installation (i.e. plumbing, power points etc.)</p>' ?>
        <?php echo $_option->getLabel() ?>
        <?php if ($_option->getIsRequire()): ?>
            <?php if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX): ?>
                <span id="options-<?php echo $_option->getId() ?>-container"></span>
            <?php endif; ?>
        <?php endif;?>

Can anyone please suggest an update to my select.phtml file below, to get this working as desired? I presume it will be a jquery on click event.

  • So you want to display a custom message based on the item selection from a select in the product page from frontend ? – Attila Naghi Aug 2 '18 at 15:29
  • Hi Chester, that's correct. Or alternatively, if that can't be done, put a message underneath a specific 'custom option' option. For example, if a custom option is 'dispose' the message 'this is a dispose option'. My current code shows the messages regardless. – YorkieMagento Aug 3 '18 at 9:54
  • Can you update your post with the generated html code ? you can get it from firebug . thnx! – Attila Naghi Aug 3 '18 at 13:45
  • Hi Chester, is there a specific part of the output you require? As there seems to be lots of html generated by this file[s], including script. – YorkieMagento Aug 10 '18 at 8:49

Your Answer

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

Browse other questions tagged or ask your own question.