title: Add a fee based on shipping method and payment method in Woocommerce
body: <p>I need to apply an additional fee when a customer can place an order with free shipping, but wants to select COD payment.
  So, Free Shipping + COD payment => fee.</p>
  
  <p>I tried unsuccessfully the following piece of code. Where am I wrong?</p>
  
  <pre><code>add_action( 'woocommerce_cart_calculate_fees','cod_fee' );
  function cod_fee() {
      global $woocommerce;
  
      if ( is_admin() &amp;&amp; ! defined( 'DOING_AJAX' ) )
          return;
  
          $chosen_gateway = WC()-&gt;session-&gt;chosen_payment_method;
          $chosen_methods = WC()-&gt;session-&gt;get( 'chosen_shipping_methods' );
          $chosen_shipping = $chosen_methods[0]; 
          $fee = 19;
          if ( $chosen_shipping == 'free_shipping' &amp;&amp; $chosen_gateway == 'cod' ) { 
          WC()-&gt;cart-&gt;add_fee( 'Spese per pagamento alla consegna', $fee, false, '' );
      }
  }
  </code></pre>