title: How to Hide Payment Method in Woocommerce based on Postal Code
body: <p>In this woocommerce setup, I have 2 Payment methods, <strong>Paypal</strong> and <strong>Cash on Delivery</strong>.</p>
  
  <p>Now how can <strong>Cash on Delivery</strong> be hidden/disabled for certain Postal codes only.</p>
  
  <p>This is the code I found on Gist</p>
  
  <pre><code>//  Disable gateway based on country
  function payment_gateway_disable_country( $available_gateways ) {
      global $woocommerce;
      if ( isset( $available_gateways['ccavenue'] ) &amp;&amp; $woocommerce-&gt;customer-&gt;get_country() &lt;&gt; 'IN' ) {
          unset(  $available_gateways['ccavenue'] );
      } else if ( isset( $available_gateways['paypal'] ) &amp;&amp; $woocommerce-&gt;customer-&gt;get_country() == 'IN' ) {
          unset( $available_gateways['paypal'] );
      }
      return $available_gateways;
  }
  add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_country' );
  </code></pre>
  
  <p><a href="https://gist.github.com/kloon/3972435">Gist Link</a></p>