Dan Dan - 1 month ago 12
PHP Question

Official Facebook Pixel WordPress Woocommerce plugin not syncing products

Been trying to get the official Facebook WP plugin at https://www.facebook.com/business/help/900699293402826 to upload our WooCommerce products to FaceBook as a shop and so the Pixel can track but having difficulties with it.

When we run the export (in the WP plugin under Woocommerce>settings)to go to Facebook only 3 of our 32 products get shown in the FB shop and have their Facebook Pixel events work properly.

On the WordPress side an error message appears "Facebook extension error: (#100) The parameter variants[1][options] is required"

This is so vague and completely useless. I can't tell why only 3 products are being synced and no more are, when they're all identical apart from the content.
Any suggestions?

Dan Dan
Answer Source

Figured out what the problem was.

The problem is that the Facebook WC plugin will either see products as 'simple' or 'variant' based on the presence of any variant options.

This is fine, however when it sees a product as a 'variant' it treats ALL of the attributes as variant attributes. This isn't always true since you can have attributes that are just attributes, and not used as variants.

The reason this causes problems is that the plugin then tries to tell FB that this attribute which is not a variant, is a variant, so it's passing in a NULL array when it shouldn't be.

The file in question is facebook-for-woocommerce/facebook-commerce.php on line 866. Changing this to:

'options' => $option_values == null ? array() : $option_values;

Will send it a blank array if it doesn't have values, instead of NULL.

This causes the products to be synced properly.

I was hoping to not have to hack at this plugin, but this is what happens when they don't write things properly. Hopefully this helps someone else trying to solve this issue.