title: WooCommerce, remove applied coupon codes from Checkout Page for selected Payment Methods
body: <p>I am trying to provide a specific discounts based on Coupons, which are applied automatically on the Checkout Page. </p>
  
  <p>Now my issue is that I want to limit these coupons for all payment methods except Cash On Delivery. Is there any way I can remove the coupon based on the selection of the payment methods on the checkout page.</p>
  
  <p>Please check the code below which is added the themes function.php to add the coupons. </p>
  
  <pre><code>add_action( 'woocommerce_after_checkout_form', 'apply_matched_coupons' );
  
  function apply_matched_coupons() {
  global $woocommerce;
  
  $coupon_code = 'spedisc10'; // your coupon code here
  
  if ( $woocommerce-&gt;cart-&gt;has_discount( $coupon_code ) ) return;
  
  if ( $woocommerce-&gt;cart-&gt;total &gt;= 1000) {
       $woocommerce-&gt;cart-&gt;add_discount( $coupon_code );
       $woocommerce-&gt;show_messages();
  }
  
  }
  </code></pre>
  
  <p>Thanks and regards,<br>
  Sandeep</p>