mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Refactoring
This commit is contained in:
parent
0ae7e6e9bc
commit
65b97f63c5
2 changed files with 9 additions and 7 deletions
|
@ -105,9 +105,16 @@ class IdentityToken {
|
|||
( $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ) )
|
||||
&& defined( 'PPCP_FLAG_SUBSCRIPTION' ) && PPCP_FLAG_SUBSCRIPTION
|
||||
) {
|
||||
$customer_id = $this->customer_repository->customer_id_for_user(($user_id));
|
||||
|
||||
if ( 0 === $user_id ) {
|
||||
$customer_id = uniqid();
|
||||
WC()->session->set( 'ppcp_guest_customer_id', $customer_id );
|
||||
}
|
||||
|
||||
$args['body'] = wp_json_encode(
|
||||
array(
|
||||
'customer_id' => $this->customer_repository->customer_id_for_user( ( $user_id ) ),
|
||||
'customer_id' => $customer_id,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -39,12 +39,7 @@ class CustomerRepository {
|
|||
public function customer_id_for_user( int $user_id ): string {
|
||||
$guest_customer_id = get_user_meta( $user_id, 'ppcp_guest_customer_id', true );
|
||||
if ( $guest_customer_id ) {
|
||||
$user_id = $guest_customer_id;
|
||||
}
|
||||
|
||||
if ( 0 === $user_id ) {
|
||||
$user_id = uniqid();
|
||||
WC()->session->set( 'ppcp_guest_customer_id', $user_id );
|
||||
return $this->prefix . $guest_customer_id;
|
||||
}
|
||||
|
||||
return $this->prefix . $user_id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue