title: WooCommerce: Check if shipping of an order is free
body: <p>I display an information about the needed amount for free shipping.</p>
  <p>Like:</p>
  <blockquote>
  <p>Add 10$ more to get free shipping</p>
  </blockquote>
  <p>That all works fine and is based on a fixed amount for the free shipping.
  My problem is now, that it will also show even if a coupon sets free shipping.
  Is there any way to check if the order already uses any free shipping method?</p>
  <p>I found something here: <a href="https://stackoverflow.com/a/32932933/1788961">https://stackoverflow.com/a/32932933/1788961</a></p>
  <pre><code>global $woocommerce;
  $shipping_methods = $woocommerce-&gt;shipping-&gt;load_shipping_methods();
  if($shipping_methods['free_shipping']-&gt;enabled == &quot;yes&quot;)
  </code></pre>
  <p>But it doesn't help.</p>
  <p>I also found an interesting snippet here: <a href="https://www.businessbloomer.com/woocommerce-hide-shipping-options-free-shipping-available/" rel="nofollow noreferrer">https://www.businessbloomer.com/woocommerce-hide-shipping-options-free-shipping-available/</a></p>
  <pre><code>$all_free_rates = array();
       
  foreach ( $rates as $rate_id =&gt; $rate ) {
        if ( 'free_shipping' === $rate-&gt;method_id ) {
           $all_free_rates[ $rate_id ] = $rate;
           break;
        }
  }
       
  if ( empty( $all_free_rates )) {
          return $rates;
  } else {
          return $all_free_rates;
  } 
   
  }
  </code></pre>