This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

Shop_Customer class

Defined in /modules/shop/models/shop_customer.php, lines 37-1377
Inheritance Phpr_Extension » Phpr_Extensible » Phpr_Validatable » Db_Base » Db_WhereBase » Db_SqlBase » Db_ActiveRecord » Shop_Customer
Author LemonStand eCommerce Inc.
Represents a customer.

Public properties

Show inherited properties.

Property Type Description Defined By
auto_create_timestamps array a list of create timestamp columns. Db_ActiveRecord
auto_timestamps boolean determines whether create and update timestamp field should be set automatically. Db_ActiveRecord
auto_update_timestamps array a list of update timestamp columns. Db_ActiveRecord
billing_city string specifies the customer billing city. Shop_Customer
billing_country Shop_Country specifies a billing country. Shop_Customer
billing_state Shop_CountryState specifies a billing state. Shop_Customer
billing_street_addr string specifies the customer billing street address. Shop_Customer
billing_zip string specifies the customer billing ZIP/postal code. Shop_Customer
calculated_columns array contains a list of calculated columns. Db_ActiveRecord
company string specifies the customer company name. Shop_Customer
created_at Phpr_DateTime specifies the date and time when the customer record was created. Shop_Customer
email string specifies the customer email. Shop_Customer
fetched array contains an associative array of table column values fetched from the database. Db_ActiveRecord
first_name string specifies the customer first name. Shop_Customer
group Shop_CustomerGroup a reference to a customer group the customer belongs to. Shop_Customer
guest boolean indicates whether the customer is a guest. Shop_Customer
has_and_belongs_to_many array contains a list of Has and Belongs To Many relations. Db_ActiveRecord
has_one array contains a list of Has One relations. Db_ActiveRecord
id integer specifies the customer record identifier. Shop_Customer
image Db_DataCollection the customer photo. The collection contains zero or one object of Db_File class. Shop_Customer
last_name string specifies the customer last name. Shop_Customer
notes string specifies the customer notes. Shop_Customer
orders Db_DataCollection a list of customer orders. Shop_Customer
phone string specifies the customer phone number. Shop_Customer
primary_key string specifies a name of the table primary key. Db_ActiveRecord
shipping_city string specifies the customer shipping city. Shop_Customer
shipping_company string specifies the shipping company name. Shop_Customer
shipping_country Shop_Country specifies a shipping country. Shop_Customer
shipping_first_name string specifies the shipping first name. Shop_Customer
shipping_last_name string specifies the shipping last name. Shop_Customer
shipping_phone string specifies the shipping phone number. Shop_Customer
shipping_state Shop_CountryState specifies a shipping state. Shop_Customer
shipping_street_addr string specifies the customer shipping street address. Shop_Customer
shipping_zip string specifies the customer shipping ZIP/postal code. Shop_Customer
updated_at Phpr_DateTime specifies the date and time when the customer record was updated last time. Shop_Customer
validation Phpr_Validation contains the model's validation object. Db_ActiveRecord

Public methods

Show inherited methods.

Method Description Defined By
add_form_custom_area() adds a form custom area. Db_ActiveRecord
add_form_field() makes a column visible in forms. Db_ActiveRecord
add_form_partial() adds a custom form partial. Db_ActiveRecord
add_form_section() adds a form section. Db_ActiveRecord
after_create_saved() called after a new object is saved to the database. Db_ActiveRecord
after_modify() called after an existing or new record was modified. Db_ActiveRecord
after_save() called after an existing or new record is created or updated in the database. Db_ActiveRecord
after_validation() triggered after the model column values are validated. Db_ActiveRecord
after_validation_on_create() triggered after a new model column values are validated. Db_ActiveRecord
after_validation_on_update() triggered after an existing model column values are validated. Db_ActiveRecord
before_update() called before an existing record is updated in the database. Db_ActiveRecord
before_validation() triggered before the model column values are validated. Db_ActiveRecord
before_validation_on_create() triggered before a new model column values are validated. Db_ActiveRecord
before_validation_on_update() triggered before an existing model column values are validated. Db_ActiveRecord
collection() executes the find_all() method and returns a collection. Db_ActiveRecord
columnValue() alias for the displayField() method. Db_ActiveRecord
copy_from_order() copies the customer name and address information from an order object. Shop_Customer
copy_to_order() copies the customer name and address information to an order object. Shop_Customer
define_column() adds a column definition to the model. Db_ActiveRecord
define_multi_relation_column() adds column definition for has_and_belongs_to_many or has_many relation field. Db_ActiveRecord
define_relation_column() adds column definition for has_on or belongs_to relation field. Db_ActiveRecord
delete() deletes the record from the database. Db_ActiveRecord
delete_customer() deletes a customer from the database or marks the customer as deleted. Shop_Customer
delete_form_field() deletes a form field by its corresponding column name. Db_ActiveRecord
displayField() returns a formatted column value. The field should be defined with define_column(), Db_ActiveRecord
find() finds a record by its primary key value. Db_ActiveRecord
find_all() finds all records and returns the Db_DataCollection object, containing a list of models. Db_ActiveRecord
find_by() finds a record by a field value. Db_ActiveRecord
find_column_definition() finds a column definition by the column name. Db_ActiveRecord
find_form_field() finds a form field definition by its corresponding column name. Db_ActiveRecord
find_registered_by_email() finds a registered customer by its email address. Shop_Customer
join() adds a table to the query with JOIN statement. Db_SqlBase
limit() allows to limit the result of the find_all() method with the specified number of records. Db_ActiveRecord
list_related_records_deferred() returns a list of relation objects, taking into account deferred relations. Db_ActiveRecord
order() allows to order the result of the find_all() method by a specific table column. Db_SqlBase
orWhere() adds OR statement to the where clause, allowing to to limit the result of the find() and find_all() methods with SQL filter. Db_WhereBase
paginate() allows to limit the result of the find_all() method with a single page of records. Db_ActiveRecord
requestRowCount() returns a number of rows which would be returned with find_all() method. Db_ActiveRecord
reset_password() finds a registered customer by email and resets their password. Shop_Customer
restore_customer() restores a customer previously deleted with delete_customer() method. Shop_Customer
save() saves record to the database. Db_ActiveRecord
send_password_restore() finds a registered customer by email and sends a password restore email. Shop_Customer
where() allows to limit the result of the find() and find_all() methods with SQL filter. Db_WhereBase

Events

Event Description
shop:onAfterCsvCustomerCreated Triggered after a new customer record has been imported from a CSV file.
shop:onAfterCsvCustomerUpdated Triggered after an existing customer record has been updated from a CSV file.
shop:onAfterCustomerMerged Triggered after a customer record is merged.
shop:onAuthenticateCustomer Allows to implement custom customer authentication scenarios.
shop:onBeforeCsvCustomerCreated Triggered before a new customer record is imported from a CSV file.
shop:onBeforeCsvCustomerUpdated Triggered before an existing customer record is updated from a CSV file.
shop:onBeforeCustomerMerged Triggered before a customer record is merged.
shop:onBeforeGenerateCustomerPassword Allows to override the default customer password generation feature.
shop:onConfigureCustomersPage Allows to configure the Administration Area customer pages before they are displayed.
shop:onCustomerAfterDelete Triggered after a customer is deleted.
shop:onCustomerCreated Triggered after a new customer is created.
shop:onCustomerUpdated Triggered after a customer is updated.
shop:onDisplayCustomersPage Allows to load extra CSS or JavaScript files on the Customer List, Customer Preview and Create/Edit Customer pages.
shop:onExtendCustomerForm Allows to add new fields to the Create/Edit Customer form in the Administration Area.
shop:onExtendCustomerModel Allows to define new columns in the customer model.
shop:onExtendCustomerPreviewTabs Allows to add tabs to the Preview Customer page in the Administration Area.
shop:onExtendCustomerPreviewToolbar Allows to add new buttons to the toolbar on the Customer Preview page in the Administration Area.
shop:onExtendCustomersToolbar Allows to add new buttons to the toolbar above the customer list in the Administration Area.
shop:onGetCustomerFieldOptions Allows to populate drop-down, radio- or checkbox list fields, which have been added with shop:onExtendCustomerForm event.
shop:onGetCustomerFieldState Determines whether a custom radio button or checkbox list option is checked.

Property details

billing_city property

public string $billing_city;
Specifies the customer billing city.

billing_country property

public Shop_Country $billing_country;
Specifies a billing country.

billing_state property

public Shop_CountryState $billing_state;
Specifies a billing state.

billing_street_addr property

public string $billing_street_addr;
Specifies the customer billing street address.

billing_zip property

public string $billing_zip;
Specifies the customer billing ZIP/postal code.

company property

public string $company;
Specifies the customer company name.

created_at property

public Phpr_DateTime $created_at;
Specifies the date and time when the customer record was created.

email property

public string $email;
Specifies the customer email.

first_name property

public string $first_name;
Specifies the customer first name.

group property

public Shop_CustomerGroup $group;
A reference to a customer group the customer belongs to.

guest property

public boolean $guest;
Indicates whether the customer is a guest.

id property

public integer $id;
Specifies the customer record identifier.

image property

public Db_DataCollection $image;
The customer photo. The collection contains zero or one object of Db_File class.

last_name property

public string $last_name;
Specifies the customer last name.

notes property

public string $notes;
Specifies the customer notes.

orders property

public Db_DataCollection $orders;
A list of customer orders. Each element of the collection is an object of the Shop_Order class.

phone property

public string $phone;
Specifies the customer phone number.

shipping_city property

public string $shipping_city;
Specifies the customer shipping city.

shipping_company property

public string $shipping_company;
Specifies the shipping company name.

shipping_country property

public Shop_Country $shipping_country;
Specifies a shipping country.

shipping_first_name property

public string $shipping_first_name;
Specifies the shipping first name.

shipping_last_name property

public string $shipping_last_name;
Specifies the shipping last name.

shipping_phone property

public string $shipping_phone;
Specifies the shipping phone number.

shipping_state property

public Shop_CountryState $shipping_state;
Specifies a shipping state.

shipping_street_addr property

public string $shipping_street_addr;
Specifies the customer shipping street address.

shipping_zip property

public string $shipping_zip;
Specifies the customer shipping ZIP/postal code.

updated_at property

public Phpr_DateTime $updated_at;
Specifies the date and time when the customer record was updated last time.

Method details

copy_from_order() method

public void copy_from_order(Shop_Order $order)
$order Shop_Order order Specifies an order object to copy data from.
Copies the customer name and address information from an order object. The method doesn't save the customer object.

copy_to_order() method

public void copy_to_order(Shop_Order $order)
$order Shop_Order order Specifies an order object to copy data to.
Copies the customer name and address information to an order object. The method doesn't save the order object.

delete_customer() method

public void delete_customer()
Deletes a customer from the database or marks the customer as deleted. If a customer has any orders associated, it cannot be deleted permanently. The method marks such customers as deleted. Deleted customers can be restored with restore_customer() method.

find_registered_by_email() method

public static Shop_Customer find_registered_by_email(string $email)
$email string specifies the customer's email address.
{return} Shop_Customer returns a customer object or NULL of the customer is not found.
Finds a registered customer by its email address.

reset_password() method

public static void reset_password(string $email)
$email string specifies the customer email address.
Finds a registered customer by email and resets their password. The method sends the shop:password_reset notification to customer. If the customer is not found, an application exception is thrown.

restore_customer() method

public void restore_customer()
Restores a customer previously deleted with delete_customer() method.

send_password_restore() method

public static void send_password_restore(string $email)
$email string specifies the customer email address.
Finds a registered customer by email and sends a password restore email. The method sends the shop:password_restore notification to customer. If the customer is not found, an application exception is thrown.