title: woocommerce: disable payment for certain categories
body: <p>i need to disable payment for certain categories on my woocommerce website. so far i have found this code, which works but for only 1 category. does anyone know how to make this work for multiple categories? thanks</p>
  
  <pre><code>&lt;?php
  /*
   * A simple filter to disable a user-specified payment gateway when a product with a user-specified category is added to the shopping cart
   *  - Note:  If multiple products are added and only one has a matching category, it will remove the payment gateway
   * Requires:
   *    payment_NAME : One of the five hardcoded Woocommerce standard types of payment gateways - paypal, cod, bacs, cheque or mijireh_checkout
   *    category_ID :   The ID of the category for which the gateway above will be removed.  Get the ID by clicking on the category under Products -&gt; Categories and reading the "tag_ID" in the address bar
   *                             i.e. http://ubuntu.humble.lan/wp-admin/edit-tags.php?action=edit&amp;taxonomy=product_cat&amp;tag_ID=20&amp;post_type=product &lt;-- the tag_ID is 20
   * Coded by sean _ at _ techonfoot.com
   * Thanks to boxoft - http://stackoverflow.com/questions/15303031/woocommerce-get-category-for-product-page
   * Usual free code disclaimer - use at your own risk
   * This code was tested against Woocommerce 2.0.8 and WordPress 3.5.1
   */
  function filter_gateways($gateways){
  
  $payment_NAME = 'paypal'; // &lt;--------------- change this
  $category_ID = '20';  // &lt;----------- and this
  
   global $woocommerce;
  
   foreach ($woocommerce-&gt;cart-&gt;cart_contents as $key =&gt; $values ) {
      // Get the terms, i.e. category list using the ID of the product
      $terms = get_the_terms( $values['product_id'], 'product_cat' );
      // Because a product can have multiple categories, we need to iterate through the list of the products category for a match
      foreach ($terms as $term) {
          // 20 is the ID of the category for which we want to remove the payment gateway
          if($term-&gt;term_id == $category_ID){
                 unset($gateways[$payment_NAME]);
                     // If you want to remove another payment gateway, add it here i.e. unset($gateways['cod']);
                      break;
            }
          break;
  </code></pre>