Orders
in package
Shop Order Helpers
Tags
Table of Contents
Constants
- usernamePrefix = 'shop_customer'
Methods
- deleteByCustomerId() : bool
- Deletes all Orders with the given Customer ID
- getArray() : array<string|int, mixed>
- Returns an array of Orders for the given parameters
- getIdArray() : array<string|int, mixed>
- Returns an array of Order IDs for the given parameters
- getListletterLinks() : string
- Returns a string with HTML code for the starting letter links
- getStatusArray() : string
- Returns the array of Order status strings, indexed by the status values
- getStatusMenu() : string
- Returns a dropdown menu string with all available order status.
- getStatusMenuoptions() : string
- Returns the HTML menu options for selecting an order status
- getSubstitutionArray() : array<string|int, mixed>
- Returns an array with all placeholders and their values to be replaced in any shop mailtemplate for the given order ID.
- update_status() : int
- Updates the status of the Order with the given ID
- updateStatusFromGet() : bool
- Updates the Order status with parameter values from the GET request
- view_list() : bool
- Sets up the Order list view
- view_statistics() : mixed
- Sets up the Order statistics
Constants
usernamePrefix
public
mixed
usernamePrefix
= 'shop_customer'
Methods
deleteByCustomerId()
Deletes all Orders with the given Customer ID
public
static deleteByCustomerId(int $customer_id) : bool
Parameters
- $customer_id : int
-
The Customer ID
Return values
bool —True on success, false otherwise
getArray()
Returns an array of Orders for the given parameters
public
static getArray(int &$count[, string $order = null ][, array<string|int, mixed> $filter = null ][, int $offset = 0 ][, int $limit = -1 ]) : array<string|int, mixed>
See getIdArray() and getById() for details.
Parameters
- $count : int
-
The actual number of Orders returned, by reference
- $order : string = null
-
The optional sorting order, SQL syntax
- $filter : array<string|int, mixed> = null
-
The optional array of filter values
- $offset : int = 0
-
The zero based offset for the list of Orders returned. Defaults to 0 (zero)
- $limit : int = -1
-
The maximum number of Orders to be returned. Defaults to -1 (no limit)
Return values
array<string|int, mixed> —The array of Order objects on success, false otherwise
getIdArray()
Returns an array of Order IDs for the given parameters
public
static getIdArray(int &$count[, string $order = null ][, array<string|int, mixed> $filter = null ][, int $offset = 0 ][, int $limit = 0 ]) : array<string|int, mixed>
The $filter array may include zero or more of the following field names as indices, plus some value or array of values that will be tested:
- id An Order ID or array of IDs
- customer_id A Customer ID or array of IDs
- status An Order status or array of status
- term An arbitrary search term. Matched against the fields company, firstname, lastname, address, city, phone, and email (shipping address).
- letter A letter (or string) that will be matched at the beginning of the fields company, firstname, or lastname. Add more fields when needed.
The $order parameter value may be one of the table field names plus an optional SQL order direction. Add Backticks to the table and field names as required. $limit defaults to 1000 if it is empty or greater. Note that the array returned is empty if no matching Order is found.
Parameters
- $count : int
-
The actual number of records returned, by reference
- $order : string = null
-
The optional sorting order field, SQL syntax. Defaults to 'id ASC'
- $filter : array<string|int, mixed> = null
-
The optional array of filter values
- $offset : int = 0
-
The optional zero based offset for the results returned. Defaults to 0 (zero)
- $limit : int = 0
-
The optional maximum number of results to be returned. Defaults to 1000
Return values
array<string|int, mixed> —The array of Order IDs on success, false otherwise
getListletterLinks()
Returns a string with HTML code for the starting letter links
public
static getListletterLinks([int $selected = null ]) : string
Parameters
- $selected : int = null
-
The optional preselected letter
Return values
string —The links HTML code
getStatusArray()
Returns the array of Order status strings, indexed by the status values
public
static getStatusArray([bool $flagFilter = false ]) : string
Adds a "Status" null element with empty string value index if the $flagFilter parameter is true.
Parameters
- $flagFilter : bool = false
-
If true, the null element is added
Return values
string —The status array
getStatusMenu()
Returns a dropdown menu string with all available order status.
public
static getStatusMenu([string $selected = '' ][, bool $flagFilter = false ][, mixed $order_id = null ][, string $onchange = '' ]) : string
If $flagFilter is true, an additional null element is added. This is intended to indicate an empty filter value only, not as an Order status to be applied!
Parameters
- $selected : string = ''
-
Optional selected status
- $flagFilter : bool = false
-
Add null elememt if true
- $order_id : mixed = null
- $onchange : string = ''
-
Optional onchange callback function
Tags
Return values
string —$menu The dropdown menu string
getStatusMenuoptions()
Returns the HTML menu options for selecting an order status
public
static getStatusMenuoptions([string $selected = '' ][, bool $flagFilter = false ]) : string
Adds a "Status" header option with empty string value if the $flagFilter parameter is true.
Parameters
- $selected : string = ''
-
The value of the preselected status
- $flagFilter : bool = false
-
If true, the header option is added
Return values
string —The HTML menu options string
getSubstitutionArray()
Returns an array with all placeholders and their values to be replaced in any shop mailtemplate for the given order ID.
public
static getSubstitutionArray(int $order_id[, bool $create_accounts = true ][, bool $updateStock = true ]) : array<string|int, mixed>
You only have to set the 'substitution' index value of your MailTemplate array to the array returned. Customer data is not included here. See Customer::getSubstitutionArray(). Note that this method is now mostly independent of the current session. The language of the mail template is determined by the browser language range stored with the order.
Parameters
- $order_id : int
-
The order ID
- $create_accounts : bool = true
-
If true, creates User accounts and Coupon codes. Defaults to true
- $updateStock : bool = true
-
If true, decreases stock according to order. Defaults to true
Tags
Return values
array<string|int, mixed> —The array with placeholders as keys and values from the order on success, false otherwise
update_status()
Updates the status of the Order with the given ID
public
static update_status(int $order_id[, int $newOrderStatus = 0 ][, string $handler = NULL ]) : int
If the order exists and has the pending status (status == 0), it is updated according to the payment and distribution type. Note that status other than pending are never changed! If the optional argument $newOrderStatus is set and not pending, the order status is set to that value instead. Returns the new Order status on success. If either the order ID is invalid, or if the update fails, returns the Order status "pending" (zero).
Parameters
- $order_id : int
-
The ID of the current order
- $newOrderStatus : int = 0
-
The optional new order status.
- $handler : string = NULL
-
The Payment type name in use
Tags
Return values
int —The new order status (may be zero) if the order status can be changed accordingly, zero otherwise
updateStatusFromGet()
Updates the Order status with parameter values from the GET request
public
static updateStatusFromGet() : bool
Tags
Return values
bool —True on success, false on failure, or null (on NOOP)
view_list()
Sets up the Order list view
public
static view_list([Sigma &$objTemplate = null ][, array<string|int, mixed> $filter = NULL ]) : bool
Sets the $objTemplate parameter to the default backend template, if empty.
Parameters
- $objTemplate : Sigma = null
-
The Template, by reference
- $filter : array<string|int, mixed> = NULL
-
The optional filter
Return values
bool —True on success, false otherwise
view_statistics()
Sets up the Order statistics
public
static view_statistics([Sigma &$objTemplate = null ]) : mixed
Parameters
- $objTemplate : Sigma = null
-
The optional Template, by reference