title: Disabling payment methods based on custom shipping methods in WooCommerce
body: <p>In WooCommerce shop I have 2 delivery method based on Parcel locker. The first is payable in advance, while the second is cash on delivery.</p>
  <p>The idea is:</p>
  <ul>
  <li>easypack_parcel_machines -&gt; only Pay in advance</li>
  <li>easypack_parcel_machines_cod -&gt; only Cash on delivery</li>
  </ul>
  <p>My code below. After applying in both cases, I only have Pay in advance. What's wrong?</p>
  <pre><code>add_filter( 'woocommerce_available_payment_gateways', 'gateway_disable_shipping_meth' );
    
  function gateway_disable_shipping_meth( $available_gateways ) {
     if ( ! is_admin() ) {
        $chosen_methods = WC()-&gt;session-&gt;get( 'chosen_shipping_methods' );      
        $chosen_shipping = $chosen_methods[0];
        
         if ( isset( $available_gateways['bacs'] ) &amp;&amp; 0 === strpos( $chosen_shipping, 'easypack_parcel_machines' ) ) {
           unset( $available_gateways['cod'] );
        }
        elseif ( isset( $available_gateways['cod'] ) &amp;&amp; 0 === strpos( $chosen_shipping, 'easypack_parcel_machines_cod' ) ) {
           unset( $available_gateways['bacs'] );
        }
     }  
     return $available_gateways;
  }
  </code></pre>