WC_Session_Handler::migrate_guest_session_to_user_session
Migrates a guest session to the current user session.
Method of the class: WC_Session_Handler{}
Hooks from the method
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->migrate_guest_session_to_user_session();
WC_Session_Handler::migrate_guest_session_to_user_session() WC Session Handler::migrate guest session to user session code WC 10.3.3
private function migrate_guest_session_to_user_session() {
$guest_session_id = $this->_customer_id;
$user_session_id = (string) get_current_user_id();
$this->_data = $this->get_session( $guest_session_id, array() );
$this->_dirty = true;
$this->_customer_id = $user_session_id;
$this->save_data( $guest_session_id );
/**
* Fires after a customer has logged in, and their guest session id has been
* deleted with its data migrated to a customer id.
*
* This hook gives extensions the chance to connect the old session id to the
* customer id, if the key is being used externally.
*
* @since 8.8.0
*
* @param string $guest_session_id The former session ID, as generated by `::generate_customer_id()`.
* @param string $user_session_id The Customer ID that the former session was converted to.
*/
do_action( 'woocommerce_guest_session_to_user_id', $guest_session_id, $this->_customer_id );
}