2

In js/varien/configurable.js, Product.config.prototype has this method that changes the displayed price of a configurable item based on the option selected from the dropdown menu:

reloadPrice: function(){
        if (this.config.disablePriceReload) {
            return;
        }
        var price    = 0;
        var oldPrice = 0;
        for(var i=this.settings.length-1;i>=0;i--){
            var selected = this.settings[i].options[this.settings[i].selectedIndex];
            if(selected.config){
                price    += parseFloat(selected.config.price);
                oldPrice += parseFloat(selected.config.oldPrice);
            }
        }

        optionsPrice.changePrice('config', {'price': price, 'oldPrice': oldPrice});
        optionsPrice.reload();

        return price;

        if($('product-price-'+this.config.productId)){
            $('product-price-'+this.config.productId).innerHTML = price;
        }
        this.reloadOldPrice();
    }

What I don't understand here is, why include the if statement and the call to reloadOldPrice() after the return? It seems like this code should never be run, so what's going on?

2

Code after a return will NEVER run. Seems like someone forgot to clean up their code!

  • You're probably right! I'm just checking my sanity on that one. Thanks! – sadq3377 Oct 6 '16 at 21:17

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.