• Resolved clementrectangle

    (@clementrectangle)


    Hi !

    I was about to make a topic to ask you why images displayed by SVI don’t get the attributes they should, more precisely, Alt texts (I’m generating custom ones using the wp_get_attachment_image_attributes hook).

    But then, I noticed the parent div have a “data-wcsvi” attribute, containing the correct alt texts, so it seems when everything works as expected, you’re indeed getting the images attributes.

    So I checked my JS console, since it seems you read this data-wcsvi attribute with JS to populate attributes for images, right ?

    And I noticed this error (I’ll give you the whole output in case it helps) :

    vendor.min.js?ver=5.1.12:1 TypeError: this.$root.$children[0].form.on is not a function
        at a.mounted (smart-variations-images-public.min.js?ver=5.1.12:1:10721)
        at Vt (vendor.min.js?ver=5.1.12:1:11408)
        at rn (vendor.min.js?ver=5.1.12:1:25328)
        at Object.insert (vendor.min.js?ver=5.1.12:1:20364)
        at x (vendor.min.js?ver=5.1.12:1:56175)
        at fo.nodeOps [as __patch__] (vendor.min.js?ver=5.1.12:1:57533)
        at t._update (vendor.min.js?ver=5.1.12:1:33783)
        at kn.r (vendor.min.js?ver=5.1.12:1:64369)
        at mn.get (vendor.min.js?ver=5.1.12:1:26754)
        at new mn (vendor.min.js?ver=5.1.12:1:26672)

    Would you have any idea why this happens ?
    I gave you a “nowprocket” link so that no additionnal minifying / optimization is applied on JS files, and no dependencies get deferred, but no luck, the problem is still there.

    Thanks !

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author David Rosendo

    (@drosendo)

    It’s the second case showing that error.

    I don’t know exactly what causes it. I will investigate this and get back asap.

    Cheers,

    Thread Starter clementrectangle

    (@clementrectangle)

    Thanks ??

    (If I can be of any help let me know).

    Plugin Author David Rosendo

    (@drosendo)

    Hello,

    So that notice shows up because I can find the variations form.

    By default WooCommerce variations form is something like:

    <form class="variations_form cart" action="https://some_url" method="post" enctype="multipart/form-data" data-product_id="12">....</form>

    This form has important information like the product ID. This helps just in case you have multiple products on the same page to target the correct “form”.

    In your case I cant find “.variations_form” specially the .reset_variations button inside. This prevents me from reseting the images.

    If you can add the class “variations_form” to the form the notice will go away.

    Cheers,

    Thread Starter clementrectangle

    (@clementrectangle)

    Hi,

    The problem is that most products on the website are not variable product, but simple ones… So it’s normal that the variable product form isn’t there.

    And I just noticed that the fallback to the default theme display is a PRO feature. I also noticed that we can disable SVI for a specific product in the Advanced tab, but since it’s not accessible from the bulk modify, we would have to disable it on every products one by one…

    It seems to me that it makes the free version of your plugin pretty unusable ??

    Isn’t there any way to fix this error for simple products, so that Alt texts are correctly applied to product images ?

    Thread Starter clementrectangle

    (@clementrectangle)

    I tried to add the following elements to simple products forms as a workaround, by modifying default simple.php woocommerce template :
    – the “variations_form” class on the form
    – the “data-product_id” attribute on the form (filled with the right ID of course)
    – a “reset_variations” button in the form, with display:none; since it’s not usefull on simple forms

    But no luck, the error is still there…

    Plugin Author David Rosendo

    (@drosendo)

    For simple products I don’t look for the form element.

    You can disable globally also via some code
    https://www.smart-variations.com/knowledge-base/how-to/disable-svi-from-running-on-certain-conditions/

    Inwil check the simple products

    Thread Starter clementrectangle

    (@clementrectangle)

    Ha !

    With that code, I can easily disable SVI for simple products only and get my Alt texts back ??

    Thank you for the help, very appreciated !

    PS : If anyone has the same problem and find this thread : the very easy condition to set in David’s snippet is : if ($product->is_type( ‘simple’ ))

    Plugin Author David Rosendo

    (@drosendo)

    Great it helps ??

    Hope to get a review off the plugin and how it works for you ??

    Cheers,
    David

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘JS error on product page (this.$root.$children[0].form.on is not a function)’ is closed to new replies.