title: Set shipping method programmatically Woocommerce
body: <p>I just created a custom Woocommerce shipping method with the id of <code>custom_shipping</code>.  The option now appears on the Woocommerce -> Settings -> Shipping admin page.  </p>
  
  <p>I would like to set the shipping method dynamically based on a user's credentials.  The default method is <code>flat_rate</code> right now.</p>
  
  <p><strong>Question:</strong>
  How can I set the shipping method to <code>custom_shipping</code> for users who meet a requirement, for the entirety of their session?</p>
  
  <p><strong>Tried:</strong></p>
  
  <pre><code>$chosen_methods = $woocommerce-&gt;session-&gt;set('chosen_shipping_methods', array('purolator_shipping');
  </code></pre>
  
  <p>This sets the session variable 'chosen_shipping_methods' correctly on my <code>cart</code> page, but upon moving to <code>checkout</code>, the session goes back to using the <code>flat_rate</code> shipping method.</p>
  
  <p>There must be a hook or filter that I can plug into to change the shipping method upon cart-session creation or something. (When a user adds something to cart for first time).</p>
  
  <p>I would ideally like to set the new shipping method before anything else is loaded so the shipping method looks correct on their cart and checkout summaries.</p>
  
  <p>Guidance appreciated.</p>