How to change user id on checkout page for assign order to different user in woocommerce wordpress

Just copy and paste below code into your theme's functions.php file or in your custom plugin file

function rj_replace_user_id_with_session_id(){
    if(!session_id()){
        session_start();
    }
    if(isset($_SESSION['order_replace_by_user_id'])){
           return $_SESSION['order_replace_by_user_id']; // return user id you want to assign order
    }
}

add_filter( 'woocommerce_checkout_customer_id', 'rj_replace_user_id_with_session_id' );

Comments

  1. Replies
    1. Hello AndySerrato,

      It's tested code and perfectly work in my project. Can you please explain me what you exactly want to do in your script so i can help. rahuljalavadiya@gmail.com is my email id . you can even email me your queries.

      Thanks

      Delete

Post a Comment

Popular posts from this blog

How to add a custom sorting or order by option on category archive or product archive page in woocommerce wordpress

How to create a custom wp_list_table and bulk action in wordpress

How to add image option in nav menu in wordpress