Magento – Custom Event on Product Option Change

optionprice

In my magento store my products have several custom options which alter the price of the product. I also need to add in a custom function which shows or hides particular content when this event triggers.

I can see that the following is called when any option ever changes:

opConfig.reloadPrice();

but i am unsure what file this actually sits in so i can add an extra function onto the event.

Best Answer

mine is defined in confiugrable.js and looks something like:

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();
}