zigojacko
zigojacko

Reputation: 2063

JS error when trying to update price on options select for bundled products in Magento

Since upgrading a Magento website from 1.8 to 1.9 and switching them onto the RWD theme, the price is not updating when selecting product options for bundled products.

The console returns the following error when you select an option:-

Uncaught TypeError: Cannot read property 'update' of null

This occurs at line 83 of bundle.js which is tierPriceElement.update(tierPriceHtml);.

This is part of the changeSelection method which in it's entirety, is included below:-

changeSelection: function(selection){
    var parts = selection.id.split('-');
    if (this.config['options'][parts[2]].isMulti) {
        selected = new Array();
        if (selection.tagName == 'SELECT') {
            for (var i = 0; i < selection.options.length; i++) {
                if (selection.options[i].selected && selection.options[i].value != '') {
                    selected.push(selection.options[i].value);
                }
            }
        } else if (selection.tagName == 'INPUT') {
            selector = parts[0]+'-'+parts[1]+'-'+parts[2];
            selections = $$('.'+selector);
            for (var i = 0; i < selections.length; i++) {
                if (selections[i].checked && selections[i].value != '') {
                    selected.push(selections[i].value);
                }
            }
        }
        this.config.selected[parts[2]] = selected;
    } else {
        if (selection.value != '') {
            this.config.selected[parts[2]] = new Array(selection.value);
        } else {
            this.config.selected[parts[2]] = new Array();
        }
        this.populateQty(parts[2], selection.value);
        var tierPriceElement = $('bundle-option-' + parts[2] + '-tier-prices'),
            tierPriceHtml = '';
        if (selection.value != '' && this.config.options[parts[2]].selections[selection.value].customQty == 1) {
            tierPriceHtml = this.config.options[parts[2]].selections[selection.value].tierPriceHtml;
        }
        tierPriceElement.update(tierPriceHtml);
    }
    this.reloadPrice();
},

I can see that the exact same issue used to exist on here but it has since been deleted.

Given this is the code that is packaged with the Magento 1.9, it is strange this is not working as expected... I did force the theme to fallback onto the template files for the base theme and the same error was triggered when trying to change the options on a bundled product.

JavaScript certainly isn't my speciality (nor debugging it), is there something not right with the above snippet? Or any suggestions on how I can find the cause of this?

Edit

It appears it is something in the theme after all as I reverted to the default RWD theme and the prices were updating - perhaps an extension or something else being called in the layout XML.

Upvotes: 0

Views: 2626

Answers (3)

Thomas Bennett
Thomas Bennett

Reputation: 647

I had a similar issue with the package default theme overwriting and breaking from a Magento 1.8 to 1.9 upgrade:

app/design/frontend/{package}/default/template/bundle/catalog/product/view/type/bundle/option/

Trick was simply to remove it, or I could have copied down rwd/default/../option and kept the base theme's classes or HTML that may have been needed.

Upvotes: 0

Thom Koopman
Thom Koopman

Reputation: 1

I had the same problem after migrating to Enterprise Edition. In my case the solution was similair to yours: renaming or removing the files in the app/design/frontend/MYPACKAGE/MYTHEME/template/bundle/catalog/product/view/type/bundle/option folder so the system falls back to the base/default/ files.

Upvotes: 0

zigojacko
zigojacko

Reputation: 2063

Eventually, via a lot of trial and error, I identified the issue, indeed caused by a 3rd party extension after all.

This culprit extension was the Magento Product Options Lightbox by Iceberg Commerce for the benefit of others that may experience this.

This extension overwrites catalog/product/view/type/bundle/option/radio.phtml with it's own version. It's own version using dated code (even though the extension claims to be compatible with Magento 1.9 it is in fact using bundled options code from an earlier version.

To fix (for those that wish to use this extension):-

Replace the entire contents of this file (iceberg/bundledoptiondetails/catalog/product/view/type/bundle/option/radio.phtml):-

With this version from my pastebin.

Upvotes: 0

Related Questions