title: Auto change Woocommerce order status Failed -> Canceled
body: <p>I am trying to automatically change Woocommerce orders with &quot;Failed&quot; status to &quot;Cancel&quot; status after 24h.
  It means the customer has not been able to pay his order.</p>
  <p>I have tried many things so far but was not able to make it work.
  Here is the mu-plugin I have created :</p>
  <pre><code>    &lt;?php
  add_action( 'woocommerce_cancel_unpaid_submitted', 'cancel_failed_orders' );
  function cancel_failed_orders() {
      $days_delay = 1; 
      $one_day    = 24 * 60 * 60;
      $today      = strtotime( date('Y-m-d') );
      $failed_orders = (array) wc_get_orders( array(
          'limit'        =&gt; -1,
          'status'       =&gt; 'wc-failed',
          'date_created' =&gt; '&lt;' . ( $today - ($days_delay * $one_day) ),
      ) );
      if ( sizeof($failed_orders) &gt; 0 ) {
          $cancelled_text = __(&quot;No successful payment&quot;, &quot;woocommerce&quot;);
          foreach ( $failed_orders as $order ) {
              $order-&gt;update_status( 'wc-cancelled', $cancelled_text );
          }
      }
  }
  </code></pre>
  <p>Does anyone has any idea what I am missing ?</p>