OpenCart 🇺🇦

Класс Customer { ... }

Название свойства Описание
Customer::$customer_id private mixed $customer_id
Customer::$firstname private mixed $firstname
Customer::$lastname private mixed $lastname
Customer::$email private mixed $email
Customer::$telephone private mixed $telephone
Customer::$fax private mixed $fax
Customer::$newsletter private mixed $newsletter
Customer::$customer_group_id private mixed $customer_group_id
Customer::$address_id private mixed $address_id
Тип Возвр. Описание
public mixed __construct ( $registry )
Исходный код метода:
$this->config = $registry->get('config');
$this->db = $registry->get('db');
$this->request = $registry->get('request');
$this->session = $registry->get('session');

if (isset($this->session->data['customer_id'])) { 
	$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$this->session->data['customer_id'] . "' AND status = '1'");

	if ($customer_query->num_rows) {
		$this->customer_id = $customer_query->row['customer_id'];
		$this->firstname = $customer_query->row['firstname'];
		$this->lastname = $customer_query->row['lastname'];
		$this->email = $customer_query->row['email'];
		$this->telephone = $customer_query->row['telephone'];
		$this->fax = $customer_query->row['fax'];
		$this->newsletter = $customer_query->row['newsletter'];
		$this->customer_group_id = $customer_query->row['customer_group_id'];
		$this->address_id = $customer_query->row['address_id'];

		$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '" . $this->db->escape(isset($this->session->data['cart']) ? serialize($this->session->data['cart']) : '') . "', wishlist = '" . $this->db->escape(isset($this->session->data['wishlist']) ? serialize($this->session->data['wishlist']) : '') . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int)$this->customer_id . "'");

		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_ip WHERE customer_id = '" . (int)$this->session->data['customer_id'] . "' AND ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "'");

		if (!$query->num_rows) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "customer_ip SET customer_id = '" . (int)$this->session->data['customer_id'] . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', date_added = NOW()");
		}
	} else {
		$this->logout();
	}
}
public bool login ( string $email, string $password, bool $override = false )
Исходный код метода:
if ($override) {
	$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer where LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND status = '1'");
} else {
	$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '" . $this->db->escape(md5($password)) . "') AND status = '1' AND approved = '1'");
}

if ($customer_query->num_rows) {
	$this->session->data['customer_id'] = $customer_query->row['customer_id'];	

	if ($customer_query->row['cart'] && is_string($customer_query->row['cart'])) {
		$cart = unserialize($customer_query->row['cart']);

		foreach ($cart as $key => $value) {
			if (!array_key_exists($key, $this->session->data['cart'])) {
				$this->session->data['cart'][$key] = $value;
			} else {
				$this->session->data['cart'][$key] += $value;
			}
		}			
	}

	if ($customer_query->row['wishlist'] && is_string($customer_query->row['wishlist'])) {
		if (!isset($this->session->data['wishlist'])) {
			$this->session->data['wishlist'] = array();
		}

		$wishlist = unserialize($customer_query->row['wishlist']);

		foreach ($wishlist as $product_id) {
			if (!in_array($product_id, $this->session->data['wishlist'])) {
				$this->session->data['wishlist'][] = $product_id;
			}
		}			
	}

	$this->customer_id = $customer_query->row['customer_id'];
	$this->firstname = $customer_query->row['firstname'];
	$this->lastname = $customer_query->row['lastname'];
	$this->email = $customer_query->row['email'];
	$this->telephone = $customer_query->row['telephone'];
	$this->fax = $customer_query->row['fax'];
	$this->newsletter = $customer_query->row['newsletter'];
	$this->customer_group_id = $customer_query->row['customer_group_id'];
	$this->address_id = $customer_query->row['address_id'];

	$this->db->query("UPDATE " . DB_PREFIX . "customer SET ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int)$this->customer_id . "'");

	return true;
} else {
	return false;
}
public void logout ( )
Исходный код метода:
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '" . $this->db->escape(isset($this->session->data['cart']) ? serialize($this->session->data['cart']) : '') . "', wishlist = '" . $this->db->escape(isset($this->session->data['wishlist']) ? serialize($this->session->data['wishlist']) : '') . "' WHERE customer_id = '" . (int)$this->customer_id . "'");

unset($this->session->data['customer_id']);

$this->customer_id = '';
$this->firstname = '';
$this->lastname = '';
$this->email = '';
$this->telephone = '';
$this->fax = '';
$this->newsletter = '';
$this->customer_group_id = '';
$this->address_id = '';
public mixed isLogged ( )
Исходный код метода:
return $this->customer_id;
public mixed getId ( )
Исходный код метода:
return $this->customer_id;
public mixed getFirstName ( )
Исходный код метода:
return $this->firstname;
public mixed getLastName ( )
Исходный код метода:
return $this->lastname;
public mixed getEmail ( )
Исходный код метода:
return $this->email;
public mixed getTelephone ( )
Исходный код метода:
return $this->telephone;
public mixed getFax ( )
Исходный код метода:
return $this->fax;
public mixed getNewsletter ( )
Исходный код метода:
return $this->newsletter;	
public mixed getCustomerGroupId ( )
Исходный код метода:
return $this->customer_group_id;	
public mixed getAddressId ( )
Исходный код метода:
return $this->address_id;	
public mixed getBalance ( )
Исходный код метода:
$query = $this->db->query("SELECT SUM(amount) AS total FROM " . DB_PREFIX . "customer_transaction WHERE customer_id = '" . (int)$this->customer_id . "'");

return $query->row['total'];
public mixed getRewardPoints ( )
Исходный код метода:
$query = $this->db->query("SELECT SUM(points) AS total FROM " . DB_PREFIX . "customer_reward WHERE customer_id = '" . (int)$this->customer_id . "'");

return $query->row['total'];	

Связанные классы:

Название класса Роль
class DB { ... } Компонент Db используется в данном классе
class Request { ... } Компонент Request используется в данном классе
class Session { ... } Компонент Session используется в данном классе

Комментарии