Support » Plugin: WooCommerce » Create WooCommerce order on new user registration

  • The goal is to create a new order when a new customer register’s in wordpress web site.
    To achieve that, the following hook was added to child theme’s functions.php:

        add_action( 'user_register', 'add_order', 10, 1 );
        
            function add_order( $user_id ) {
            
                $order = wc_create_order();
                $order->set_customer_id($user_id);
                $order->save();
            }

    However, when a new user registers, new order is created in DB , but is not displayed in wp-admin->woocommerce->orders. No error is seen in the log.

  • The topic ‘Create WooCommerce order on new user registration’ is closed to new replies.