woocommerce / facebook-for-woocommerce

A first-party extension plugin built for WooCommerce. Development is managed by Ventures.
https://woocommerce.com/products/facebook/
GNU General Public License v2.0
211 stars 140 forks source link

Product Sets JS alert about excluded categories always displays #2741

Closed layoutd closed 6 months ago

layoutd commented 6 months ago

πŸ”Ž Isolate the bug

✍️ Describe the bug

πŸšΆβ€β™€οΈ Steps to reproduce

  1. Connect FB and exclude a category with products.
  2. Create a product set that includes the excluded category.
  3. The JS alert You have selected one or more categories currently excluded from the Facebook sync. Products belonging to the excluded categories will not be added to your Facebook Product Set. displays.
  4. Create another product set containing a NON-excluded category.
  5. The JS alert still displays.

βœ”οΈ Expected behavior

The JS alert should only display if an excluded category is actually included in the product set.

πŸ”§ Solution

The culprit is the comparison in this function: https://github.com/woocommerce/facebook-for-woocommerce/blob/2eab66267d706fc46beed78e2c7506ccc347130f/assets/js/admin/product-sets-admin.js#L58-L68

Obviously, excludedCategories[i] will always be in the excludedCategories array! πŸ˜†