Woocommerce

How To Assign An Order To A Different User In Woocommerce

Here we learn about how to assign an order to a different user in WooCommerce.

Custom code copied and paste into your child theme’s functions.php or custom plugin file.

Example 1: Pass user id you want to assign order using manually.

<?php
function myblog_replace_user_id_with_session_id(){
  //pass user id you want to assign order.
  $set_user_id = '2';
  return $set_user_id;    
}
add_filter( 'woocommerce_checkout_customer_id', 'myblog_replace_user_id_with_session_id' );

Example 2: Pass user id you want to assign order using session.

<?php
function myblog_replace_user_id_with_session_id(){
  if( !session_id() ){
    session_start();
  }
  if( isset( $_SESSION['order_by_user_id'] ) ){
    //pass user id you want to assign order.
    return $_SESSION['order_by_user_id'];
  }
}
add_filter( 'woocommerce_checkout_customer_id', 'myblog_replace_user_id_with_session_id' );
?>

OUTPUT:

Rahul Prajapat

I’m Rahul Prajapat. I’m a WordPress developer and Author at TheCodeHubs. I have good skill of Html, CSS, JQuery, SQL, Web API, PSD to HTML/PSD to WordPress, WordPress Theme/Plugin Customization, create or modify short code, customize visual composer short code or integrate new short code with visual composer, can create custom metabox for any post type in WordPress admin.

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

3 years ago