title: woocommerce tiered flat rate based on a custom field
body: <p>I have a website where customer chooses a zone in a dropdown in billing fields. These are 4 zones: zone1, zone2 and zone3 as an example.</p>
  
  <p>The idea is that if customer chose zone1 and total cart is less than $1000, customer needs to pay a shipping rate of $100. If more than $1000, customer gets free shipping.</p>
  
  <p>I need to replicate that for the other 2 zones with different cart amounts and shipping rates.  Is this possible?</p>
  
  <p>Right now, I have the following working code but customer has to manually choose a flat rate. Problem is, of course, customers... If free shipping is displayed, they will choose that one knowing they dont apply for that option when total amount is less for their zone.</p>
  
  <pre><code>/* Change shipping based on total cost purchased. */
  add_filter( 'woocommerce_package_rates', 'bbloomer_woocommerce_tiered_shipping', 10, 2 );
  function bbloomer_woocommerce_tiered_shipping( $rates, $package ) {
  $threshold_centro = 1000; 
  $threshold_hasta_el_5 = 1500;
  $threshold_arelauquen = 2000;
  if ( WC()-&gt;cart-&gt; cart_contents_total &lt; $threshold_centro ) {
  unset( $rates['free_shipping:9'] );
  } 
  elseif ( WC()-&gt;cart-&gt; cart_contents_total &lt; $threshold_hasta_el_5 ) {
  unset( $rates['flat_rate:2'] ); 
  } 
  elseif ( WC()-&gt;cart-&gt; cart_contents_total &lt; $threshold_arelauquen ) {
  unset( $rates['flat_rate:2'], $rates['flat_rate:3'] ); 
  } 
  else {
  unset( $rates['flat_rate:2'], $rates['flat_rate:3'], $rates['flat_rate:4'], $rates['flat_rate:5'], $rates['flat_rate:6'] );
  } 
  return $rates; 
  }
  </code></pre>
  
  <p>and the custom field is this one: billing_wcccf_id_qXZZegrC774HULq</p>