Facebook-for-woocommerce: JS Error "Cannot read property 'split' of undefined" in single product edit page

Created on 14 Apr 2020  路  5Comments  路  Source: facebookincubator/facebook-for-woocommerce

Console error in single product, upon updating a product.
The product can't be updated anymore.

Uncaught TypeError: Cannot read property 'split' of undefined
    at HTMLInputElement.<anonymous> (facebook-for-woocommerce-products-admin.min.js:1)
    at HTMLInputElement.dispatch (load-scripts.php:3)
    at HTMLInputElement.r.handle (load-scripts.php:3)

Specifically it's this line:

, r = n('textarea[name="tax_input[product_tag]"]').val().split(",")

We don't have/use product tags, it shouldn't be assumed stores do.
We have hidden the metabox and deregistered the taxonomy.

Most helpful comment

Hey @Jany-M @lakrisgubben @baritchie, I'm sorry the plugin triggered this error on your websites. Thank you for reporting the problem and suggesting a solution!

We just released version 1.11.0 of Facebook for WooCommerce. That version includes a fix for this JS error. You should be able to publish or update products without issues again, even when tags are not used.

All 5 comments

Just got bitten by the same issue, products can no longer be updated or published because of the above mentioned js-error that's triggered if product tags are deregistered.

Simple fix for it is to change line 202 of facebook-for-woocommerce-products-admin.js to something like productTag = $( 'textarea[name="tax_input[product_tag]"]' ).length ? $( 'textarea[name="tax_input[product_tag]"]' ).val().split( ',' ) : [], (and of course use the non-minified version).

@lakrisgubben I have fixed it for now, but it's important they fix it in the next update too.

I am getting this same error, but I do not have product tags deregistered. Exact same error however, disables me from updating any products unless I disable the plugin temporarily. @lakrisgubben is this a safe fix if tags are being used?

is this a safe fix if tags are being used?

Yep, the code simply says "if tags are empty don't freak out" :)

Hey @Jany-M @lakrisgubben @baritchie, I'm sorry the plugin triggered this error on your websites. Thank you for reporting the problem and suggesting a solution!

We just released version 1.11.0 of Facebook for WooCommerce. That version includes a fix for this JS error. You should be able to publish or update products without issues again, even when tags are not used.

Was this page helpful?
0 / 5 - 0 ratings