title: Conditional coupon error messages on WooCommerce
body: <p>I am trying to build a WooCommerce checkout page with an open coupon form by disabling the toggle. I modified the code given in <a href="https://stackoverflow.com/a/49273237/1809542">here</a> by adding the following to it so it removes the big blue notification message too. </p>
  
  <pre><code>$(".showcoupon").closest(".woocommerce-info").hide();  
  </code></pre>
  
  <p>Only issue is if someone clicks the Apply Coupon with an empty or incorrect coupon code, it displays the error and hides the coupon code field. Therefore I added the below so it gives the user another chance to get the coupon form.</p>
  
  <pre><code>add_filter( 'woocommerce_coupon_error', 'pm_change_coupon_error', 30, 3 );
  
  function pm_change_coupon_error( $err, $err_code, $coupon ){
  
  if (is_checkout()) {        
      $err =  ' &lt;a class="showcoupon"&gt;' . __( 'Click here to enter a valid coupon code', 'woocommerce' ) . '&lt;/a&gt;';    
  }
  else {
      $err  =  'Please enter a valid code'; //Error message for cart page
  }
  return $err;
  }
  </code></pre>
  
  <p>No matter what modifications I tried, it always displays the error message given for the else statement. How can I make sure there will always be 2 separate messages depending on the page?</p>