1
votes

I've successfully modified the Product Information > Custom options form to allow the entry for the quantity of the particular option. Now I'm working towards getting the quantity to appear in the drop down list on the product view page next to the "Title" and "Fixed Price" .

Through some research, I've been able to trace the responsible file for the option layout to:

app/design/frontend/default/MY_TEMPLATE/template/catalog/product/view/options/type/select.phtml

however now I'm not sure as to which code I need to modify to display the quantity within the drop down list. Any help would be much appreciated!

Here is the code from the select.phtml file:

<?php 

// start my custom

        $_option = $this->getOption();

        $configValue = $this->getProduct()->getPreconfiguredValues()->getData('options/' . $_option->getId());

        $store = $this->getProduct()->getStore();



        if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN

            || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) {

            $require = ($_option->getIsRequire()) ? ' required-entry' : '';

            $extraParams = '';

            $select = $this->getLayout()->createBlock('core/html_select')

                ->setData(array(

                    'id' => 'select_'.$_option->getId(),

                    'class' => $require.' product-custom-option'

                ));

            if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN) {

                $title_options =  ($_option->getIsRequire())?$this->htmlEscape($_option->getTitle())." *":$this->htmlEscape($_option->getTitle()) ;



                $select->setName('options['.$_option->getid().']')

                    ->addOption('', $title_options );

            } else {

                $select->setName('options['.$_option->getid().'][]');

                $select->setClass('multiselect'.$require.' product-custom-option');

            }

            foreach ($_option->getValues() as $_value) {

                if( $_value->getPrice(($_value->getPriceType() == 'percent') )== 0){

                    $sign = '+';

                    $priceStr = $sign . $this->helper('core')->currencyByStore(0, $store, true, false);

                }

                else{

                    $priceStr = $this->_formatPrice(array(

                        'is_percent'    => ($_value->getPriceType() == 'percent'),

                        'pricing_value' => $_value->getPrice(($_value->getPriceType() == 'percent'))

                    ), false);

                }

                $select->addOption(

                    $_value->getOptionTypeId(),

                    $_value->getTitle() . ' ' . $priceStr . '',

                    array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false))

                );

            }

            if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) {

                $extraParams = ' multiple="multiple"';

            }

            if (!$this->getSkipJsReloadPrice()) {

                $extraParams .= ' onchange="opConfig.reloadPrice()"';

            }

            $select->setExtraParams($extraParams);



            if ($configValue) {

                $select->setValue($configValue);

            }



            $selectHtml = $select->getHtml();

        }

// end my custom

?>

getOption(); ?> getIsRequire()) echo ' class="required"' ?>>getIsRequire()) echo '*' ?>htmlEscape($_option->getTitle()) ?> */?>

decoratedIsLast){?> class="last">

<div class="input-box">
getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) { ?>
    <?php echo $selectHtml; ?>

<?php 

    } else{ 

        echo $this->getValuesHtml(); ?>

<?php } ?>

    <?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;?>

</div>

1

1 Answers

1
votes

Yes, should override class

Mage_Catalog_Block_Product_View_Options_Type_Select

and change

$_value->getTitle() . ' ' . $priceStr . '',

to

$_value->getTitle() . ' (' . $_value->getQty() . ') ' . $priceStr . '',

where Qty is Magento index, under which quantity is saved.