The problem was caused by another method inside the class:
public function create_cart_id() {
if( is_user_logged_in() ) {
$this->create_logged_in_cart_id();
}else {
$this->create_non_logged_in_cart_id();
}
return $this->cart_id; - adding that line solved the problem
}
This method generates the $cart_id, but it didn’t return its value, so it was not accessible from outside and returned null.