• Hello,

    I’m not sure that this is the best way to communicate about observed errors, but I would like to raise an issue with the botiga/assets/js/custom.min.js file.

    Uncaught TypeError: Cannot read properties of null (reading ‘classList’)
    at Object.events (custom.min.js?ver=1.0.8:1)
    at Object.init (custom.min.js?ver=1.0.8:1)
    at HTMLDocument.<anonymous> (custom.min.js?ver=1.0.8:1)

    The error is raised from the line 675 of the non minified custom.js file

    plus.classList.add(‘show’);

    When there is only 1 or less item in stock (woocommerce), the “.botiga-quantity-plus” element is not added to html. The div container “.quantity” also has the “.hidden” class and a single child of <input>, hidden with quantity 1.

    Therefore, the search (line 673)
    var plus = qty[i].querySelector(‘.botiga-quantity-plus’)
    returns null and the .classList.add function raises the previously mentionned error.

    I suggest that the code should be edited to either apply the code from line 675 to 692 if the plus and minus element are not null, or to alter the preceding search for elements to only include non ‘.hidden’ quantity container

    var qty = document.querySelectorAll(‘form.cart .quantity, .botiga-quick-view-popup .quantity, .woocommerce-cart-form__cart-item.cart_item .quantity, .botiga-single-sticky-add-to-cart-wrapper-content .quantity’);

    (the last propose solution may have unknown side effect)

    Best regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @abrowet,

    First thanks for using our theme and reporting that JS error!

    We fixed that for the next theme update by checking if the quantity input has the class “hidden”.

    You can await for the next theme update that we should release soon. Or, follow the instructions below for a temporary solution:

    1. Install and activate the TC Custom JavaScript plugin
    2. Go To Appearance > Custom JavaScript
    3. Paste the following code into the provided box: https://pastebin.com/raw/RApbVFUk

    Thanks for your suggestions in how to resolve that issue as well.

    We hope this helps!

    Kind Regards,

    Rodrigo.

    Thread Starter abrowet

    (@abrowet)

    Dear,

    Thank you for your reply and for the proposed solution.

    Though, I’ll rather add an enqueued temporary js file from my child theme than adding yet another plugin 🙂

    function botiga_fix_scripts()
    {
    if (BOTIGA_VERSION === ‘1.0.8’) {
    wp_enqueue_script(‘botiga-fix’, get_stylesheet_directory_uri() . ‘/js/botiga-fix.js’, array(), PUNKICKS_VERSION, true);
    }
    }
    add_action(‘wp_enqueue_scripts’, ‘botiga_fix_scripts’, 20);`

    Best regards

    • This reply was modified 4 years, 5 months ago by abrowet.

    Hi @abrowet,

    You are welcome!

    Definitely, to experienced developers like you, adding the code through a child theme is better than through a plugin 🙂

    Thanks for sharing the code here, so others can use the same.

    Kind Regards,

    Rodrigo.

    • This reply was modified 4 years, 5 months ago by maaprote.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘JS uncaught TypeError’ is closed to new replies.