如何删除在magento的可配置产品中选择一个选项? [关闭]

I am building a magento project. In configurable product, before choosing an option, price is being displayed. I need to modify it like either hide price until user choose an option or make any one option as default in dropdown. I have gone through google and found a script to hide choose an option in dropdown. But it is not working. I`m using magento 1.8.

Can you guys please guide me to achieve this. Here is the link of code I found:

http://inchoo.net/ecommerce/magento/how-to-make-configurable-options-autoselected-on-configurable-product-view-page/

Kandarp B Patel's answer may help you remove "Choose an option" option. It provides some modifications to Inchoo's code on the page you referenced.

Magento's forum answered how to remove the price from the configurable product options dropdown.

Alternatively, you could remove configurable option pricing with jQuery.

How to remove the "Choose an Option" element from the drop down

Tested with Magento v1.9.2.1

Add the following JavaScript to your page. There is only 3 lines here that have been edited from the original logic found in js/varien/configurable.js. I've left these lines in there, commented out for you to see what has been modified.

Product.Config.prototype.fillSelect = function(element){
    var attributeId = element.id.replace(/[a-z]*/, '');
    var options = this.getAttributeOptions(attributeId);
    this.clearSelect(element);
    //element.options[0] = new Option('', '');
    //element.options[0].innerHTML = this.config.chooseText;

    var prevConfig = false;
    if(element.prevSetting){
        prevConfig = element.prevSetting.options[element.prevSetting.selectedIndex];
    }

    if(options) {
        //var index = 1;
        var index = 0;
        for(var i=0;i<options.length;i++){
            var allowedProducts = [];
            if(prevConfig) {
                for(var j=0;j<options[i].products.length;j++){
                    if(prevConfig.config.allowedProducts
                        && prevConfig.config.allowedProducts.indexOf(options[i].products[j])>-1){
                        allowedProducts.push(options[i].products[j]);
                    }
                }
            } else {
                allowedProducts = options[i].products.clone();
            }

            if(allowedProducts.size()>0){
                options[i].allowedProducts = allowedProducts;
                element.options[index] = new Option(this.getOptionLabel(options[i], options[i].price), options[i].id);
                if (typeof options[i].price != 'undefined') {
                    element.options[index].setAttribute('price', options[i].price);
                }
                element.options[index].config = options[i];
                index++;
            }
        }
    }
}