Search code examples
magentomagento-1.7magento-1.9magento2magento-1.8

Magento checkout jquery function null error


I'm getting error TypeError: $(...) is null and TypeError: $(...).visible is null.

In onepage checkout jquery function which is if($('checkout-step-shipping').visible() || $('checkout-step-shipping_method').visible())

Please let me know what may cause this problem

function styleRegionInterval() {
    if (!intervalInit) {
        styleRegion = setInterval(styleRegionInput, 500);
        intervalInit = true;
    }
}
function styleRegionInput() {
    if($('checkout-step-shipping').visible() || $('checkout-step-shipping_method').visible()) {
        clearInterval(styleRegion);
        intervalInit = false;
        shippingRegionUpdater.update();
    }
}

Some days before i had removed shipping method but my checkout was working fine without it.

There is same on billing or register page of checkout to continue button as function calls there.


Solution

  • Try using jQuery('checkout-step-shipping').visible() instead of $('checkout-step-shipping').visible().

    Your could should look like:

    function styleRegionInterval() {
        if (!intervalInit) {
            styleRegion = setInterval(styleRegionInput, 500);
            intervalInit = true;
        }
    }
    function styleRegionInput() {
        if(jQuery('checkout-step-shipping').visible() || jQuery('checkout-step-shipping_method').visible()) {
            clearInterval(styleRegion);
            intervalInit = false;
            shippingRegionUpdater.update();
        }
    }