• Resolved weaselnerd

    (@weaselnerd)


    JavaScript error (“Uncaught DOMException: The operation is insecure.” in Firefox) emitted from cart_widget.min.js if cookies/sessionStorage is blocked

    The issue can be reproduced by disabling all cookies in the browser settings (my tests were in Firefox). The error will display in the browser console and had the effect of breaking the product variant selectors on my site. It is due to sessionStorage being blocked by the browser (or a content blocker).

    I have temporarily worked around it by adding another try…catch statement around the first sessionStorage call in a modified copy of cart_widget.js:

    
    jQuery(document).ready(function ($) {
    
        try {
            var empty_cart_hash = sessionStorage.getItem('woocommerce_cart_hash') == '';
        } catch(err) {
            var empty_cart_hash = '';
        }
        if ( empty_cart_hash || actions.is_lang_switched == 1 || actions.force_reset == 1 ) {
            wcml_reset_cart_fragments();
        }
    });
    
    function wcml_reset_cart_fragments(){
        try {
            jQuery(document).ready(function () {
                jQuery(document.body).trigger('wc_fragment_refresh');
                //backward compatibility for WC < 3.0
                sessionStorage.removeItem('wc_fragments');
            });
        } catch(err){}
    }
    

    I know disabling all cookies will break WooCommerce cart functionality completely, but this is just to reproduce the issue. At least one customer managed to have content blocking settings (I lack the specifics) that broke our product variation selector allowing them to choose the largest size item with no price change, resulting in a drastically underpriced, yet placed order.

    Hoping this can be fixed in a future plugin update.

    Cheers,
    sean

Viewing 1 replies (of 1 total)
  • Thank you for the report Sean!

    I will pass this along to our Dev team to test and hopefully resolve in future versions.

    Best,
    Izzi

Viewing 1 replies (of 1 total)
  • The topic ‘Breaking JavaScript error when cookies/sessionStorage blocked’ is closed to new replies.