title: Display an estimated delivery date range based on WooCommerce cart item stock
body: <p>I am trying to output an estimated delivery date in the cart based on the stock status of the products in the cart. </p>
  
  <p>I was a little bit successful but now I am stuck. </p>
  
  <p>This is what I have written so far. It goes in the function.php</p>
  
  <pre><code>function lieferzeit() {
  
      global $woocommerce;
          $cart_items = $woocommerce-&gt;cart-&gt;get_cart();
          foreach ($cart_items as $variation) {
              $variation_id = $variation['variation_id'];
           $variation_obj = new WC_Product_variation($variation_id);
           $stock = $variation_obj-&gt;get_stock_quantity();
          }
  echo $stock; //outputs the in stock amount successfully
  
  }
  
  
  add_filter ( 'woocommerce_cart_collaterals', 'lieferzeit');
  </code></pre>
  
  <p>Now I am trying to add the estimated date but here I am stuck</p>
  
  <pre><code>function lieferzeit() {
  
      global $woocommerce;
          $cart_items = $woocommerce-&gt;cart-&gt;get_cart();
          foreach ($cart_items as $variation) {
              $variation_id = $variation['variation_id'];
           $variation_obj = new WC_Product_variation($variation_id);
           $stock = $variation_obj-&gt;get_stock_quantity();
          }
  
          for ($i=0; $i &lt; count($stock) ; $i++) {
              echo "Voraussichtliche Lieferung Date! ";
  
  
          }
  }
  
  add_filter ( 'woocommerce_cart_collaterals', 'lieferzeit');
  </code></pre>
  
  <p>Here the date output have to be defined. From today +1 day until from today +4 days. But I don't have an idea how to manage that. 
  The best output would be this format:</p>
  
  <p><strong>Estimated shipping Fri. 14.7 - Wed. 19.7</strong> </p>
  
  <p>I am not even shure if </p>
  
  <pre><code>for ($i=0; $i &lt; count($stock) ; $i++) {
  </code></pre>
  
  <p>is the right way to go. </p>
  
  <p>I do have two types of products, one can be shipped within 1-4 days and the other is within 14-21 days. Now is second problem. When both types are in the cart the higher shipping time should be selected. </p>
  
  <p>Are there some ideas?</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>The code should check the stock quantity of each item in the cart. 
  If all items have a stock quantity greater than 0 it should echo an estimated shipping time of 1 to 4 working days given as a date.</p>
  
  <p>If there is one item in cart with a stock quantity of 0 or below it should echo an estimate shipping time of 14 - 21 working days given as a date. Even if all the other items in the cart have a stock quantity greater than 0.  </p>
  
  <p>Working days should be monday until friday. Very neat would be if the code recognizes holidays too e.g. christmas, new year etc..</p>
  
  <p>Thanks</p>
  
  <blockquote>
    <p>The solution from LoicTheAztec works perfect. Now I tried to add some more option to it. </p>
  </blockquote>
  
  <p>It would be nice if the output of <code>function lieferzeit()</code> would be displayed in the admin order details page. 
  To create a custom admin panel in the sidebar I found </p>
  
  <pre><code>    add_action( 'add_meta_boxes', 'add_meta_boxes' );
  function add_meta_boxes()
  {
      add_meta_box( 
          'woocommerce-order-my-custom', 
          __( 'Order Custom' ), 
          'order_my_custom', 
          'shop_order', 
          'side', 
          'default' 
      );
  }
  
  function order_my_custom()
  {
     echo $lieferzeit;
  }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/24179529/how-to-add-custom-fields-for-woocommerce-order-page-admin">from this post</a> </p>
  
  <p>This works so far and there is a Order Custom tab in the admin page. Now I tried to store the output of <code>function lieferzeit()</code> in a variable.</p>
  
  <pre><code>$from = str_replace($days_en, $days_ge, $from);
  $to   = str_replace($days_en, $days_ge, $to);
  
  $lieferzeit = array($from, $to);
  </code></pre>
  
  <p>But it seems that <code>function add_meta_boxes()</code> and <code>function order_my_custom()</code> doen't know nothing of the variable <code>$lieferzeit</code>.</p>
  
  <p>Is there another way to store and recall the output of <code>function lieferzeit()</code> ? </p>