title: Auto restock products on specific order status changes in Woocommerce
body: <p>I picked up this code snippet and have been messing with it. I'm getting some syntax errors…</p>
  
  <p>Here is that code:</p>
  
  <pre><code>class Comfythemes_Woocommerce_Auto_Stock_Restore {
  
      function __construct() {
          add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'restore_order_stock' ), 10, 1 );
          add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'restore_order_stock' ), 10, 1 );
          add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'restore_order_stock' ), 10, 1 );
          add_action( 'woocommerce_order_status_processing_to_refunded', array( $this, 'restore_order_stock' ), 10, 1 );
          add_action( 'woocommerce_order_status_completed_to_refunded', array( $this, 'restore_order_stock' ), 10, 1 );
          add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'restore_order_stock' ), 10, 1 );
      }
      public function restore_order_stock( $order_id ) {
          $order = new WC_Order( $order_id );
  
          if ( ! get_option('woocommerce_manage_stock') == 'yes' &amp;amp;&amp;amp; ! sizeof( $order-&gt;get_items() ) &gt; 0 ) {
              return;
          }
          foreach ( $order-&gt;get_items() as $item ) {
              if ( $item['product_id'] &gt; 0 ) {
  
                  $_product = $order-&gt;get_product_from_item( $item );
  
                  if ( $_product &amp;amp;&amp;amp; $_product-&gt;exists() &amp;amp;&amp;amp; $_product-&gt;managing_stock() ) {
  
                      $old_stock = $_product-&gt;stock;
                      $qty = apply_filters( 'woocommerce_order_item_quantity', $item['qty'], $this, $item );
                      $new_quantity = $_product-&gt;increase_stock( $qty );
                      do_action( 'woocommerce_auto_stock_restored', $_product, $item );
                      $order-&gt;add_order_note( sprintf( __( 'Item #%s stock incremented from %s to %s.', 'woocommerce' ), $item['product_id'], $old_stock, $new_quantity) );
                      $order-&gt;send_stock_notifications( $_product, $new_quantity, $item['qty'] );
                  }
              }
          }
      }
  }
  
  new Comfythemes_Woocommerce_Auto_Stock_Restore();
  </code></pre>
  
  <p>Im getting some errors on line 14 and 22... couldn't figure this out. Any ideas?</p>
  
  <p>How to get this Auto restock feature on specific orders status changes in woocommerce 3?</p>