Merge pull request #449 from woocommerce/PCP-511-pre-release-client_id-string-too

Generate unique id based on the length of the prefix
This commit is contained in:
Emili Castells 2022-01-26 09:53:57 +01:00 committed by GitHub
commit fc5589612c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,6 +13,7 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Repository;
* Class CustomerRepository
*/
class CustomerRepository {
const CLIENT_ID_MAX_LENGTH = 22;
/**
* The prefix.
@ -43,7 +44,7 @@ class CustomerRepository {
return $guest_customer_id;
}
$unique_id = $this->prefix . uniqid();
$unique_id = substr( $this->prefix . strrev( uniqid() ), 0, self::CLIENT_ID_MAX_LENGTH );
WC()->session->set( 'ppcp_guest_customer_id', $unique_id );
return $unique_id;