Change SKU number of product for returning clients in thankyou hook
<p>In WooCommerce, I am trying to change a product SKU of an order received by a returning client. <br>
Currently I use the current code but it does not seem to work.</p>

<p>I have 2 different products. The product with id <strong><code>5836</code></strong> is a normal product while the other is a subscription.</p>

<p>This is my code:</p>

<pre><code>function action_woocommerce_thankyou( $order_id ) {  
    // Let's get the order details
    $order = wc_get_order( $order_id );

    // Customer who made the purchase
    $user_id = $order-&gt;get_user_id();

    // Now get order count for the customer
    $order_count = wc_get_customer_order_count( $user_id );
    $items = $order-&gt;get_items();

    foreach ( $order-&gt;get_items() as $item_id =&gt; $item) {
        $product_name = $item['name'];
        $product_id = $item['product_id'];
        $product_variation_id = $item['variation_id'];


        if ( $order_count &gt; 1) {

            // Returning customer...
            if ( $product_id == '5836') {
            update_post_meta( $order_id['product_id'],  '_sku', $ANT0001 );}
            else {

            // Returning customer...
            update_post_meta( $order_id['product_id'],  '_sku', $ANT0002 );}


        } else {

            // New customer...

        }

    }
}
add_action( 'woocommerce_thankyou', 'action_woocommerce_thankyou', 10, 1 ); 
</code></pre>