title: Conditionally hiding et showing payment gateways
body: <p>In Woocommerce, I would like to hide <strong>"paypal"</strong> gateway on the <strong>"checkout"</strong> page before the order is created for the first time and just show <strong>"cash on delivery"</strong> gateway (labeled as <strong>Reserve</strong>). </p>
  
  <p>On the other hand, on checkout/order-pay page when the order status is <strong>"pending"</strong>, hide the <strong>'Reserve'</strong> gateway and show <strong>"paypal"</strong>. (this happens when we change the status of the order to <strong>"pending"</strong> manually and send the invoice to the customer with a payment link).</p>
  
  <p>I thought it should be done by checking order status and using the <strong><code>woocommerce_available_payment_gateways</code></strong> filter hook. But I have problems with getting current order status. </p>
  
  <p>Also I'm not sure what's the status of a newly created order which the user is on the checkout page and still the order is not shown in the admin backend. </p>
  
  <p>This is my incomplete code:</p>
  
  <pre><code>function myFunction( $available_gateways ) {
  
      // How to check if the order's status is not pending payment?
      // How to pass the id of the current order to wc_get_order()?
       $order = wc_get_order($order_id); 
  
      if ( isset($available_gateways['cod']) &amp;&amp; /* pending order status?? */ ) { 
          // hide "cod" gateway
      } else {
          // hide "paypal" gateway
      }
      return $available_gateways;
  }
  add_filter( 'woocommerce_available_payment_gateways', 'myFunction' );
  </code></pre>
  
  <p>I also tried <code>WC()-&gt;query_vars['order']</code> instead of <code>wc_get_order();</code> to <a href="https://stackoverflow.com/a/39409201/190929">get the current order</a> and check its status but it didn't work too. </p>
  
  <p>I <a href="https://stackoverflow.com/a/24388445/190929">saw</a> <code>woocommerce_order_items_table</code> action hook but couldn't get the order either.</p>
  
  <p>How could I retrieve the Id and the status of the order on the checkout/order-pay page?</p>