Check that wc session exists before using it

This commit is contained in:
Alex P 2022-09-13 10:16:15 +03:00
parent b549f71d77
commit ad523e0973

View file

@ -107,7 +107,11 @@ class VaultingModule implements ModuleInterface {
add_action(
'woocommerce_created_customer',
function( int $customer_id ) use ( $subscription_helper ) {
$guest_customer_id = WC()->session->get( 'ppcp_guest_customer_id' );
$session = WC()->session;
if ( ! $session ) {
return;
}
$guest_customer_id = $session->get( 'ppcp_guest_customer_id' );
if ( $guest_customer_id && $subscription_helper->cart_contains_subscription() ) {
update_user_meta( $customer_id, 'ppcp_guest_customer_id', $guest_customer_id );
}