Titel
Permalink
Indhold
| Old | New |
|---|
| 1 | | 1 | # Customers
|
|---|
| | 2 |
|
|---|
| | 3 | Customers is a collection of users that can sign in to your website for accessing a history of purchases etc.
|
|---|
| | 4 |
|
|---|
| | 5 | It is not mandatory to have a customer account in order to make purchases. If a customer registers an account after they have been making purchases as guests they will be able to access their purchase history if it has the same email address.
|
|---|
| | 6 |
|
|---|
| | 7 | ## Entity Object
|
|---|
| | 8 |
|
|---|
| | 9 | ```php
|
|---|
| | 10 | $customer = new ent_customer();
|
|---|
| | 11 | $customer->data['email'] = 'user@email.com';
|
|---|
| | 12 | $customer->data['firstname'] = 'John';
|
|---|
| | 13 | $customer->data['lastname'] = 'Doe';
|
|---|
| | 14 | $customer->save();
|
|---|
| | 15 | ```
|
|---|
| | 16 |
|
|---|
| | 17 | ## Reference Model
|
|---|
| | 18 |
|
|---|
| | 19 | ```php
|
|---|
| | 20 | echo reference::customer(123)->firstname;
|
|---|
| | 21 | ```
|
|---|
| | 22 |
|
|---|
| | 23 | ## Database Query
|
|---|
| | 24 |
|
|---|
| | 25 | ```php
|
|---|
| | 26 | $query = database::query(
|
|---|
| | 27 | "select * from ". DB_TABLE_PREFIX ."customers
|
|---|
| | 28 | where id = ". (int)$customer_id ."
|
|---|
| | 29 | limit 1;"
|
|---|
| | 30 | );
|
|---|
| | 31 |
|
|---|
| | 32 | $customer = database::fetch($query);
|
|---|
| | 33 | ``` |
|---|
Edited by tim on 22 jan. 2024 at 14:17