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' );
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' );
does not work :( please help
ReplyDeleteHello AndySerrato,
DeleteIt'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