mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Do not regenerate guest customer id if already exist in the session
This commit is contained in:
parent
c2834df32f
commit
dce8a06953
2 changed files with 8 additions and 5 deletions
|
@ -107,10 +107,6 @@ class IdentityToken {
|
|||
) {
|
||||
$customer_id = $this->customer_repository->customer_id_for_user( ( $user_id ) );
|
||||
|
||||
if ( 0 === $user_id ) {
|
||||
WC()->session->set( 'ppcp_guest_customer_id', $customer_id );
|
||||
}
|
||||
|
||||
$args['body'] = wp_json_encode(
|
||||
array(
|
||||
'customer_id' => $customer_id,
|
||||
|
|
|
@ -38,7 +38,14 @@ class CustomerRepository {
|
|||
*/
|
||||
public function customer_id_for_user( int $user_id ): string {
|
||||
if ( 0 === $user_id ) {
|
||||
return $this->prefix . uniqid();
|
||||
if ( WC()->session->get( 'ppcp_guest_customer_id' ) ) {
|
||||
return WC()->session->get( 'ppcp_guest_customer_id' );
|
||||
}
|
||||
|
||||
$unique_id = $this->prefix . uniqid();
|
||||
WC()->session->set( 'ppcp_guest_customer_id', $unique_id );
|
||||
|
||||
return $unique_id;
|
||||
}
|
||||
|
||||
$guest_customer_id = get_user_meta( $user_id, 'ppcp_guest_customer_id', true );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue