Documentation

Order
in package

Shop Order

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Reto Kohli reto.kohli@comvation.com

version
3.0.0
subpackage

module_shop

Table of Contents

Constants

STATUS_CANCELLED  = 3
STATUS_COMPLETED  = 4
STATUS_CONFIRMED  = 1
STATUS_DELETED  = 2
STATUS_MAX  = 7
Total number of states.
STATUS_PAID  = 5
STATUS_PENDING  = 0
Order status constant values
STATUS_SHIPPED  = 6
UPLOAD_FOLDER  = 'media/Shop/upload/'
Folder name for (image) file uploads in the Shop

Properties

$address  : mixed
$billing_address  : mixed
$billing_city  : mixed
$billing_company  : mixed
$billing_country_id  : mixed
$billing_email  : mixed
$billing_fax  : mixed
$billing_firstname  : mixed
$billing_gender  : mixed
$billing_lastname  : mixed
$billing_phone  : mixed
$billing_zip  : mixed
$city  : mixed
$company  : mixed
$country_id  : mixed
$currency_id  : mixed
$customer_id  : mixed
$date_time  : mixed
$firstname  : mixed
$gender  : mixed
$id  : mixed
$ip  : mixed
$lang_id  : mixed
$lastname  : mixed
$modified_by  : mixed
$modified_on  : mixed
$note  : mixed
$payment_amount  : mixed
$payment_id  : mixed
$phone  : mixed
$shipment_amount  : mixed
$shipment_id  : mixed
$status  : mixed
$sum  : mixed
$vat_amount  : mixed
$zip  : mixed

Methods

address()  : string
Returns the address (shipment address)
billing_address()  : string
Returns the address (billing address)
billing_city()  : string
Returns the city (billing address)
billing_company()  : string
Returns the company (billing address)
billing_country_id()  : int
Returns the Country ID (billing address)
billing_email()  : string
Returns the e-mail address (customer)
billing_fax()  : string
Returns the fax number (billing address)
billing_firstname()  : string
Returns the first name (billing address)
billing_gender()  : string
Returns the gender (billing addres)
billing_lastname()  : string
Returns the last name (billing address)
billing_phone()  : string
Returns the phone number (billing address)
billing_zip()  : string
Returns the zip (billing address)
city()  : string
Returns the city (shipment address)
clearShipment()  : mixed
Clear all shipment related properties
company()  : string
Returns the company (shipment address)
country_id()  : int
Returns the Country ID (shipment address)
currency_id()  : int
Returns the Currency ID
customer_id()  : int
Returns the Customer ID
date_time()  : string
Returns the date and time the Order was placed
delete()  : bool
Deletes this Order
deleteById()  : bool
Deletes the Order with the given ID
deleteOptions()  : bool
Delete the options associated with the given item ID
errorHandler()  : bool
Handles database errors
firstname()  : string
Returns the first name (shipment address)
gender()  : string
Returns the gender (shipment address)
getById()  : Order
Returns the Order for the ID given
getFirstOrderTime()  : int
Returns the time() value representing the date and time of the first Order present in the database
getItemIdArray()  : array<string|int, mixed>
Returns an array of item IDs for the given Order ID
getItems()  : array<string|int, mixed>
Returns an array of items contained in this Order
getLanguageIdByCustomerId()  : int
Returns the most recently used language ID found in the order table for the given Customer ID
getOptionArray()  : array<string|int, mixed>
Returns an array of Attributes and chosen options for this Order
id()  : int
Returns the Order ID
insert()  : int
Inserts a new Order into the database table
insertAttribute()  : bool
Add the option IDs of the given Attribute ID to the Order item
insertItem()  : bool
Inserts a single item into the database
ip()  : string
Returns the IP address
isStockDecreasable()  : bool
Is given status can decrease stock
isStockIncreasable()  : bool
Is given status can increase stock
lang_id()  : int
Returns the language ID
lastname()  : string
Returns the last name (shipment address)
modified_by()  : string
Returns the user name of the User that last edited this Order
modified_on()  : string
Returns the date and time the Order was last edited
note()  : string
Returns the order note
payment_amount()  : float
Returns the payment fee
payment_id()  : int
Returns the Payment ID
phone()  : string
Returns the phone number (shipment address)
setId()  : mixed
Set the Order id
shipment_amount()  : float
Returns the shipment fee
shipment_id()  : int
Returns the Shipment ID
status()  : int
Returns the status
storeFromPost()  : bool
Stores the Order
sum()  : float
Returns the total sum, including fees and tax
updateItem()  : bool
Updates a single item in the database
updateStock()  : mixed
Update related product stock
vat_amount()  : float
Returns the VAT amount
view_detail()  : bool
Set up the detail view of the selected order
view_items()  : float
View of this Orders' items
zip()  : string
Returns the zip (shipment address)

Constants

UPLOAD_FOLDER

Folder name for (image) file uploads in the Shop

public mixed UPLOAD_FOLDER = 'media/Shop/upload/'

Note that this is prepended with the document root when necessary.

Properties

$billing_address

protected mixed $billing_address = ''

$billing_company

protected mixed $billing_company = ''

$billing_country_id

protected mixed $billing_country_id = 0

$billing_firstname

protected mixed $billing_firstname = ''

$billing_gender

protected mixed $billing_gender = ''

$billing_lastname

protected mixed $billing_lastname = ''

$date_time

protected mixed $date_time = '0000-00-00 00:00:00'

$modified_on

protected mixed $modified_on = '0000-00-00 00:00:00'

$payment_amount

protected mixed $payment_amount = 0.0

$shipment_amount

protected mixed $shipment_amount = 0.0

Methods

address()

Returns the address (shipment address)

public address([string $address = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$address : string = null

The optional address

Return values
string

The address

billing_address()

Returns the address (billing address)

public billing_address([string $billing_address = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$billing_address : string = null

The optional address

Return values
string

The address

billing_city()

Returns the city (billing address)

public billing_city([string $billing_city = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$billing_city : string = null

The optional city

Return values
string

The city

billing_company()

Returns the company (billing address)

public billing_company([string $billing_company = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$billing_company : string = null

The optional company

Return values
string

The company

billing_country_id()

Returns the Country ID (billing address)

public billing_country_id([int $billing_country_id = null ]) : int

Optionally sets the value first if the parameter value is an integer greater than zero. Note that the value is not verified other than that. This value is zero unless it has been set before.

Parameters
$billing_country_id : int = null

The optional Country ID

Return values
int

The Country ID

billing_email()

Returns the e-mail address (customer)

public billing_email([string $billing_email = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$billing_email : string = null

The optional e-mail address

Return values
string

The e-mail address

billing_fax()

Returns the fax number (billing address)

public billing_fax([string $billing_fax = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$billing_fax : string = null

The optional fax number

Return values
string

The fax number

billing_firstname()

Returns the first name (billing address)

public billing_firstname([string $billing_firstname = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$billing_firstname : string = null

The optional first name

Return values
string

The first name

billing_gender()

Returns the gender (billing addres)

public billing_gender([mixed $billing_gender = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. Valid values are defined by the User_Profile_Attribute class. This value is the empty string unless it has been set before.

Parameters
$billing_gender : mixed = null
Return values
string

The gender

billing_lastname()

Returns the last name (billing address)

public billing_lastname([string $billing_lastname = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$billing_lastname : string = null

The optional last name

Return values
string

The last name

billing_phone()

Returns the phone number (billing address)

public billing_phone([string $billing_phone = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$billing_phone : string = null

The optional phone number

Return values
string

The phone number

billing_zip()

Returns the zip (billing address)

public billing_zip([string $billing_zip = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$billing_zip : string = null

The optional zip

Return values
string

The zip

city()

Returns the city (shipment address)

public city([string $city = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$city : string = null

The optional city

Return values
string

The city

clearShipment()

Clear all shipment related properties

public clearShipment() : mixed

Called by insert() when there is no shipment ID

company()

Returns the company (shipment address)

public company([string $company = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$company : string = null

The optional company

Return values
string

The company

country_id()

Returns the Country ID (shipment address)

public country_id([mixed $country_id = null ]) : int

Optionally sets the value first if the parameter value is an integer greater than zero. Note that the value is not verified other than that. This value is zero unless it has been set before.

Parameters
$country_id : mixed = null
Return values
int

The Country ID

currency_id()

Returns the Currency ID

public currency_id([int $currency_id = null ]) : int

Optionally sets the value first if the parameter value is an integer greater than zero This value is null unless it has been set before.

Parameters
$currency_id : int = null

The optional Currency ID

Return values
int

The Currency ID

customer_id()

Returns the Customer ID

public customer_id([int $customer_id = null ]) : int

Optionally sets the value first if the parameter value is an integer greater than zero This value is null unless it has been set before.

Parameters
$customer_id : int = null

The optional Customer ID

Return values
int

The Customer ID

date_time()

Returns the date and time the Order was placed

public date_time([string $date_time = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is verified and interpreted using strtotime(). If the resulting time is non-zero, it is accepted and converted to DATETIME format. This value is '0000-00-00 00:00:00' unless it has been set before.

Parameters
$date_time : string = null

The optional order date and time

Return values
string

The order date and time, in DATETIME format

delete()

Deletes this Order

public delete() : bool
Return values
bool

True on success, false otherwise

deleteById()

Deletes the Order with the given ID

public static deleteById(int $order_id[, bool $stockUpdate = false ]) : bool
Parameters
$order_id : int

The Order ID

$stockUpdate : bool = false

True to update stock of the product

Return values
bool

True on success, false otherwise

deleteOptions()

Delete the options associated with the given item ID

public static deleteOptions(int $item_id) : bool

Will add error messages using Message::error(), if any.

Parameters
$item_id : int

The Order item ID

Return values
bool

True on success, false otherwise

errorHandler()

Handles database errors

public static errorHandler() : bool

Also migrates the old database structure to the new one

Return values
bool

False. Always.

firstname()

Returns the first name (shipment address)

public firstname([string $firstname = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$firstname : string = null

The optional first name

Return values
string

The first name

gender()

Returns the gender (shipment address)

public gender([string $gender = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. Valid values are defined by the User_Profile_Attribute class. This value is the empty string unless it has been set before.

Parameters
$gender : string = null

The optional gender

Return values
string

The gender

getById()

Returns the Order for the ID given

public static getById(int $id) : Order

If the ID is invalid or no record is found for it, returns null.

Parameters
$id : int

The Order ID

Return values
Order

The object on success, null otherwise

getFirstOrderTime()

Returns the time() value representing the date and time of the first Order present in the database

public static getFirstOrderTime() : int

Returns null if there is no Order, or on error.

Return values
int

The first Order time, or null

getItemIdArray()

Returns an array of item IDs for the given Order ID

public static getItemIdArray(int $order_id) : array<string|int, mixed>

Mind that the returned array may be empty. On failure, returns null.

Parameters
$order_id : int

The Order ID

Return values
array<string|int, mixed>

The array of item IDs on success, null otherwise

getItems()

Returns an array of items contained in this Order

public getItems([mixed $withHtmlNotation = true ]) : array<string|int, mixed>
Parameters
$withHtmlNotation : mixed = true
Tags
global

ADONewConnection $objDatabase

global

array $_ARRAYLANG

todo

Let items be handled by their own class

Return values
array<string|int, mixed>

The items array on success, false otherwise

getLanguageIdByCustomerId()

Returns the most recently used language ID found in the order table for the given Customer ID

public static getLanguageIdByCustomerId(int $customer_id) : int

Note that this method must be used for migrating old Shop Customers ONLY. It returns null if no order is found, or on error.

Parameters
$customer_id : int

The Customer ID

Return values
int

The language ID on success, null otherwise

getOptionArray()

Returns an array of Attributes and chosen options for this Order

public getOptionArray([mixed $withHtmlNotation = true ]) : array<string|int, mixed>

Options for uploads are linked to their respective files The array looks like this: array( item ID => array( "Attribute name" => array( Attribute ID => array 'name' => "option name", 'price' => "price", ), [... more ...] ), ), [... more ...] ) Note that the array may be empty.

Parameters
$withHtmlNotation : mixed = true
Return values
array<string|int, mixed>

The Attribute/option array on success, null otherwise

id()

Returns the Order ID

public id() : int

This value is null unless it has been stored before.

Return values
int

The Order ID

insert()

Inserts a new Order into the database table

public insert() : int

Does not handle items nor attributes, see insertItem() and insertAttribute() for that. Fails if the ID is non-empty, or if the record cannot be inserted for any reason. Does not insert the shipment related properties if the shipment ID is empty. Those fields SHOULD default to NULL.

Return values
int

The ID of the record inserted on success, false otherwise

insertAttribute()

Add the option IDs of the given Attribute ID to the Order item

public static insertAttribute(int $item_id, int $attribute_id, array<string|int, mixed> $arrOptionIds) : bool

Will add error messages using Message::error(), if any. The $arrOptionIds array must have the form array(attribute_id => array(option_id, ...))

Parameters
$item_id : int

The Order item ID

$attribute_id : int

The Attribute ID

$arrOptionIds : array<string|int, mixed>

The array of option IDs

Tags
static
Return values
bool

True on success, false otherwise

insertItem()

Inserts a single item into the database

public static insertItem(int $order_id, int $product_id, string $name, float $price, int $quantity, float $vat_rate, int $weight, array<string|int, mixed> $arrOptions) : bool

Note that all parameters are mandatory. All of $order_id, $product_id, and $quantity must be greater than zero. The $weight must not be negative. If there are no options, set $arrOptions to the empty array. Sets an error Message in case there is anything wrong.

Parameters
$order_id : int

The Order ID

$product_id : int

The Product ID

$name : string

The item name

$price : float

The item price (one unit)

$quantity : int

The quantity (in units)

$vat_rate : float

The applicable VAT rate

$weight : int

The item weight (in grams, one unit)

$arrOptions : array<string|int, mixed>

The array of selected options

Tags
global

ADONewConnection $objDatabase

global

array $_ARRAYLANG

static
Return values
bool

True on success, false otherwise

ip()

Returns the IP address

public ip([string $ip = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$ip : string = null

The optional IP address

Return values
string

The IP address

isStockDecreasable()

Is given status can decrease stock

public isStockDecreasable(int $oldStatus, int $newStatus) : bool
Parameters
$oldStatus : int

Old order status

$newStatus : int

New order status

Return values
bool

True when given status can decrease stock, False otherwise

isStockIncreasable()

Is given status can increase stock

public isStockIncreasable(int $oldStatus, int $newStatus) : bool
Parameters
$oldStatus : int

Old order status

$newStatus : int

New order status

Return values
bool

True when given status can increase stock, False otherwise

lang_id()

Returns the language ID

public lang_id([int $lang_id = null ]) : int

Optionally sets the value first if the parameter value is an integer greater than zero This value is zero unless it has been set before.

Parameters
$lang_id : int = null

The optional language ID

Return values
int

The language ID

lastname()

Returns the last name (shipment address)

public lastname([string $lastname = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$lastname : string = null

The optional last name

Return values
string

The last name

modified_by()

Returns the user name of the User that last edited this Order

public modified_by([string $modified_by = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$modified_by : string = null

The optional user name

Return values
string

The user name

modified_on()

Returns the date and time the Order was last edited

public modified_on([string $modified_on = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is verified and interpreted using strtotime(). If the resulting time is non-zero, it is accepted and converted to DATETIME format. This value is '0000-00-00 00:00:00' unless it has been set before.

Parameters
$modified_on : string = null

The optional edit date and time

Return values
string

The edit date and time, in DATETIME format

note()

Returns the order note

public note([string $note = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$note : string = null

The optional order note

Return values
string

The order note

payment_amount()

Returns the payment fee

public payment_amount([float $payment_amount = null ]) : float

Optionally sets the value first if the parameter value is a float greater than or equal to zero. Note that the value is not verified other than that. This value is zero unless it has been set before. It is interpreted as an amount in the Currency specified by the Currency ID.

Parameters
$payment_amount : float = null

The optional payment fee

Return values
float

The payment fee

payment_id()

Returns the Payment ID

public payment_id([int $payment_id = null ]) : int

Optionally sets the value first if the parameter value is an integer greater than zero This value is null unless it has been set before.

Parameters
$payment_id : int = null

The optional Payment ID

Return values
int

The Payment ID

phone()

Returns the phone number (shipment address)

public phone([string $phone = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$phone : string = null

The optional phone number

Return values
string

The phone number

setId()

Set the Order id

public setId(int $id) : mixed
Parameters
$id : int

shipment_amount()

Returns the shipment fee

public shipment_amount([float $shipment_amount = null ]) : float

Optionally sets the value first if the parameter value is a float greater than or equal to zero. Note that the value is not verified other than that. This value is zero unless it has been set before. It is interpreted as an amount in the Currency specified by the Currency ID.

Parameters
$shipment_amount : float = null

The optional shipment fee

Return values
float

The shipment fee

shipment_id()

Returns the Shipment ID

public shipment_id([int $shipment_id = null ]) : int

Optionally sets the value first if the parameter value is an integer greater than or equal to zero. A zero Shipper ID represents "no shipment required". This value is null unless it has been set before.

Parameters
$shipment_id : int = null

The optional Shipment ID

Tags
todo

Must be properly named "shipper_id"

Return values
int

The Shipment ID

status()

Returns the status

public status([int $status = null ]) : int

Optionally sets the value first if the parameter value is an integer greater than or equal to zero. Note that the value is not verified other than that. This value is zero unless it has been set before.

Parameters
$status : int = null

The optional status

Return values
int

The status

storeFromPost()

Stores the Order

public static storeFromPost() : bool

Takes all values as found in the POST array

Tags
global

array $_ARRAYLANG Language array

global

ADONewConnection $objDatabase Database connection object

static
Return values
bool

True on success, false otherwise

sum()

Returns the total sum, including fees and tax

public sum([float $sum = null ]) : float

Optionally sets the value first if the parameter value is a float greater than or equal to zero. Note that the value is not verified other than that. This value is zero unless it has been set before. It is interpreted as an amount in the Currency specified by the Currency ID.

Parameters
$sum : float = null

The optional sum

Return values
float

The sum

updateItem()

Updates a single item in the database

public static updateItem(int $item_id, int $product_id, string $name, float $price, int $quantity, float $vat_rate, int $weight, array<string|int, mixed> $arrOptions) : bool

Note that all parameters are mandatory. All of $item_id, $product_id, and $quantity must be greater than zero. The $weight must not be negative. If there are no options, set $arrOptions to the empty array. Sets an error Message in case there is anything wrong.

Parameters
$item_id : int

The item ID

$product_id : int

The Product ID

$name : string

The item name

$price : float

The item price (one unit)

$quantity : int

The quantity (in units)

$vat_rate : float

The applicable VAT rate

$weight : int

The item weight (in grams, one unit)

$arrOptions : array<string|int, mixed>

The array of selected options

Tags
global

ADONewConnection $objDatabase

global

array $_ARRAYLANG

static
Return values
bool

True on success, false otherwise

updateStock()

Update related product stock

public updateStock([bool $increaseStock = true ]) : mixed
Parameters
$increaseStock : bool = true

True to increase stock, false to decrease

vat_amount()

Returns the VAT amount

public vat_amount([float $vat_amount = null ]) : float

Optionally sets the value first if the parameter value is a float greater than or equal to zero. Note that the value is not verified other than that. This value is zero unless it has been set before. It is interpreted as an amount in the Currency specified by the Currency ID.

Parameters
$vat_amount : float = null

The optional VAT amount

Return values
float

The VAT amount

view_detail()

Set up the detail view of the selected order

public static view_detail([Sigma &$objTemplate = null ][, bool $edit = false ]) : bool
Parameters
$objTemplate : Sigma = null

The Template, by reference

$edit : bool = false

Edit if true, view otherwise

Tags
access

public

global

ADONewConnection $objDatabase Database connection object

global

array $_ARRAYLANG Language array

static
author

Reto Kohli reto.kohli@comvation.com

version
3.1.0
Return values
bool

True on success, false otherwise

view_items()

View of this Orders' items

public view_items(HTML_Template_Sigma $objTemplate, type $edit[, type &$total_weight = 0 ][, type $i = 0 ]) : float
Parameters
$objTemplate : HTML_Template_Sigma

The template

$edit : type

If true, items are editable

$total_weight : type = 0

Initial value for the total item weight, by reference. Usually empty or zero

$i : type = 0

Initial value for the row count, by reference. Usually empty or zero.

Tags
global

ADONewConnection $objDatabase

global

array $_ARRAYLANG

Return values
float

The net item sum on success, false otherwise

zip()

Returns the zip (shipment address)

public zip([string $zip = null ]) : string

Optionally sets the value first if the parameter value is a non-empty string. Note that the value is not verified other than that. This value is the empty string unless it has been set before.

Parameters
$zip : string = null

The optional zip

Return values
string

The zip


        
On this page

Search results