Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an action to link sessions to customer ids. #45146

Merged
merged 3 commits into from Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,4 @@
Significance: minor
Type: add

Add the `woocommerce_guest_session_to_user_id` action hook that fires when a guest session is migrated to a customer ID
14 changes: 14 additions & 0 deletions plugins/woocommerce/includes/class-wc-session-handler.php
@@ -1,4 +1,4 @@
<?php

Check notice on line 1 in plugins/woocommerce/includes/class-wc-session-handler.php

View workflow job for this annotation

GitHub Actions / Analyze Branch Changes

new action found - woocommerce_guest_session_to_user_id

\'woocommerce_guest_session_to_user_id\' introduced in 8.8.0
/**
* Handle data for the current customers session.
* Implements the WC_Session abstract class.
Expand Down Expand Up @@ -108,6 +108,20 @@
$this->_dirty = true;
$this->save_data( $guest_session_id );
$this->set_customer_session_cookie( true );

/**
* 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 int $customer_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 );
}

// Update session if its close to expiring.
Expand Down