title: Disable add to cart button for an array of products IDs in WooCommerce
body: <p>In WooCommerce, I'm trying to disable add to cart button for an array of product IDs but I can't find the problem. </p>
  
  <p>I am trying to use this function:</p>
  
  <pre><code>add_filter('woocommerce_is_purchasable', 'my_woocommerce_is_purchasable', 10, 2);
  
  function my_woocommerce_is_purchasable($is_purchasable, $product) {
      $id=check(); // This function return an array of IDs
      foreach ($id as $id_p){
          return ($product-&gt;id = $id_p ? false : $is_purchasable);
      }
  }
  </code></pre>
  
  <p>And this is my <code>check()</code> function code <em>(update)</em>:</p>
  
  <pre><code>function check() { 
      $listproduit = get_woocommerce_product_list();
      $score = get_score_user(); 
      foreach ($listproduit as $products) { 
          if ($products[1] &gt;= 5000) { 
              $listid = $products[0]; 
              return $listid; 
              // print_r($listid); 
          } 
      } 
      return $listid; 
  }
  </code></pre>
  
  <p>But this doesn't work.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks</p>