title: Woocommerce Conditional Options from Payment Method Selection
body: <p>I am wondering if someone can help me with the following code. I am trying to set some conditional html dependent on which payment method the user selects on checkout. On the payment method page I am using the following function to update the payment method information: </p>
  
  <pre><code>function cart_update_script() {
  if (is_checkout()) :
  ?&gt;
  &lt;script&gt;
      jQuery( function( $ ) {
  
  
          // woocommerce_params is required to continue, ensure the object exists
          if ( typeof woocommerce_params === 'undefined' ) {
              return false;
          }
  
          $checkout_form = $( 'form.checkout' );
  
          $checkout_form.on( 'change', 'input[name="payment_method"]', function() {
                  $checkout_form.trigger( 'update' );
          });
  
      });
  
  &lt;/script&gt;
  &lt;?php
  endif;
  }
  add_action( 'wp_footer', 'cart_update_script', 999 );
  </code></pre>
  
  <p>On the final checkout page I am then getting that selected payment method with this bit of code: </p>
  
  <pre><code>&lt;?php $chosen_gateway = WC()-&gt;session-&gt;chosen_payment_method; ?&gt;
  </code></pre>
  
  <p>Then I am using conditional statements like the following:</p>
  
  <pre><code>&lt;?php if ( $chosen_gateway == 'stripe' ) { ?&gt;
       //do this
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>My problem is that I am not getting dynamic information when the user changes payment method. Sometimes the code works but sometimes it still thinks a different payment method was selected. Any help would be great!</p>