Blesta Source Documentation

OrderForms extends OrderModel

Order Form Management

Table of Contents

Methods

add() Add an order form
delete() Permanently deletes the given order form
edit() Edit an order form
emptyToNull() Converts an empty string to a null value
get() Fetches the order form with the given ID
getAll() Returns all order forms in the system for the given company
getByLabel() Fetches the order form with the given label for the given company
getList() Returns the total number of order forms for the given company
getListCount() Returns the total number of order forms for the given company
getNoticeIntervals() Retrieves a list of abandoned order reminder intervals in hours
getPriceBreakdown() Breaks down pricing into different time periods
getSavingsPercentage() Compares two pricings and calculates the percentage of savings
getSupportedTypes() Returns all supported order type for the given template
getTemplates() Fetches all templates available to the plugin and the order types they support
getTypes() Fetches all order types available to the plugin
getVisibilities() Returns all supported visbilities in key/value pairs
search() Retrieves a list of order forms based on the given search criteria
sortOrderForms() Save the order forms in the provided order
validateAbandonedReminder() Checks if a value is valid for the abandoned reminder notice
validateClientGroup() Validates that the given client group exists and is part of the current company
validatePendingOrdersExists() Validates whether or not there are any pending orders for the given order form
validateTemplate() Validates that the given order form template supports the given order form type
validateTermsRequired() Validates whether or not the terms of service URL is required
validateUnique() Validates whether or not the given
getCurrencies() Returns all currencies set for the given form ID
getDeleteFormRules() Returns all validation rules to check when deleting an order form
getFormRules() Returns all validation rules for adding/editing forms
getGateways() Returns all gateways set for the given form ID
getGroups() Returns all order form groups set for the given form ID
getMeta() Returns all meta fields set for the given form ID
getOrderForm() Returns a partial order form query
restrictGroups() Applies filters for the given record
setCurrencies() Sets currencies for the given order form
setGateways() Sets gateways for the given order form
setGroups() Sets package groups for the given order form
setMeta() Sets meta fields for the given order form
Methods

add()

Add an order form

public add(array<string|int, mixed> $vars) : int
Parameters
$vars : array<string|int, mixed>

An array of order form data including:

  • company_id (optional, defaults to current company ID)
  • label The label used to access the order form
  • name The name of the order form
  • description The description of the order form
  • template The template to use for the order form
  • template_style The template style to use for the order form
  • type The type of order form
  • client_group_id The default client group to assign clients to when ordering from this order form
  • manual_review Whether or not to require all orders placed to be manually reviewed (default 0)
  • allow_coupons Whether or not to allow coupons (default 0)
  • require_ssl Whether or not to force secure connection (i.e. HTTPS) (default 0)
  • require_captcha Whether or not to force captcha (default 0)
  • require_tos Whether or not to require Terms of Service agreement (default 0)
  • tos_url The URL to the terms of service agreement (optional)
  • abandoned_cart_first The number of days after an unpaid order is placed to send the first reminder email (optional)
  • abandoned_cart_second The number of days after an unpaid order is placed to send the second reminder email (optional)
  • abandoned_cart_third The number of days after an unpaid order is placed to send the third reminder email (optional)
  • abandoned_cart_cancellation The number of days after an unpaid order is placed to cancel the order (optional)
  • inactive_after_cancellation Whether or not to mark a client as inactive after cancellation if this order/service is their first one (optional)
  • status The status of the order form (active/inactive default active)
  • visibility The visbility control for the order form (public, shared, client)
  • meta An array of key/value pairs to assign to this order form (optional dependent upon the order type)
  • groups An array of package group IDs to assign to this order form (optional dependent upon the order type)
  • gateways An array of gateway ID to assign to this order form (optional dependent upon the order type)
  • currencies An array of ISO 4217 currency codes to assign to this order form (optional dependent upon the order type)
Return values
int

The ID of the order form that was created, void on error

delete()

Permanently deletes the given order form

public delete(int $order_form_id) : mixed
Parameters
$order_form_id : int

The ID of the order form to delete

edit()

Edit an order form

public edit(int $order_form_id, array<string|int, mixed> $vars) : int
Parameters
$order_form_id : int

The ID of the order form to edit

$vars : array<string|int, mixed>

An array of order form data including:

  • company_id (optional, defaults to current company ID)
  • label The label used to access the order form
  • name The name of the order form
  • description The description of the order form
  • template The template to use for the order form
  • template_style The template style to use for the order form
  • type The type of order form
  • client_group_id The default client group to assign clients to when ordering from this order form
  • manual_review Whether or not to require all orders placed to be manually reviewed (default 0)
  • allow_coupons Whether or not to allow coupons (default 0)
  • require_ssl Whether or not to force secure connection (i.e. HTTPS) (default 0)
  • require_captcha Whether or not to force captcha (default 0)
  • require_tos Whether or not to require Terms of Service agreement (default 0)
  • tos_url The URL to the terms of service agreement (optional)
  • abandoned_cart_first The number of days after an unpaid order is placed to send the first reminder email (optional)
  • abandoned_cart_second The number of days after an unpaid order is placed to send the second reminder email (optional)
  • abandoned_cart_third The number of days after an unpaid order is placed to send the third reminder email (optional)
  • abandoned_cart_cancellation The number of days after an unpaid order is placed to cancel the order (optional)
  • inactive_after_cancellation Whether or not to mark a client as inactive after cancellation if this order/service is their first one (optional)
  • status The status of the order form (active/inactive default active)
  • visibility The visbility control for the order form (public, shared, client)
  • meta An array of key/value pairs to assign to this order form (optional dependent upon the order type)
  • groups An array of package group IDs to assign to this order form (optional dependent upon the order type)
  • gateways An array of gateway ID to assign to this order form (optional dependent upon the order type)
  • currencies An array of ISO 4217 currency codes to assign to this order form (optional dependent upon the order type)
Return values
int

The ID of the order form that was updated, void on error

emptyToNull()

Converts an empty string to a null value

public emptyToNull(mixed $value) : mixed
Parameters
$value : mixed

The value to evaluate

Return values
mixed

null if the value is an empty string, $value otherwise

get()

Fetches the order form with the given ID

public get(int $order_form_id[, array<string|int, mixed> $query = [] ]) : mixed
Parameters
$order_form_id : int

The ID of the order form to fetch on

$query : array<string|int, mixed> = []

Optional criteria to query on:

  • client_id int The client ID to compare package restrictions to
  • restrict_groups Whether to restrict package base on client settings
Return values
mixed

A stdClass object representing the order form, false if no such order form exists

getAll()

Returns all order forms in the system for the given company

public getAll(int $company_id, string $status[, array<string|int, mixed> $order = ['id' => 'desc'] ]) : array<string|int, mixed>
Parameters
$company_id : int

The ID of the company to fetch order forms for

$status : string

The status of the order forms to fetch:

  • "active" Only active order forms
  • "inactive" Only inactive order forms
  • null All order forms
$order : array<string|int, mixed> = ['id' => 'desc']

A key/value pair array of fields to order the results by

Return values
array<string|int, mixed>

An array of stdClass objects, each representing an order form

getByLabel()

Fetches the order form with the given label for the given company

public getByLabel(int $company_id, int $label[, array<string|int, mixed> $query = [] ]) : mixed
Parameters
$company_id : int

The ID of the company to fetch on

$label : int

The label of the order form to fetch on

$query : array<string|int, mixed> = []

Optional criteria to query on:

  • client_id int The client ID to compare package restrictions to
  • restrict_groups Whether to restrict package base on client settings
Return values
mixed

A stdClass object representing the order form, false if no such order form exists

getList()

Returns the total number of order forms for the given company

public getList(int $company_id[, int $page = 1 ][, array<string|int, mixed> $order = ['id' => 'desc'] ][, string $status = null ]) : array<string|int, mixed>
Parameters
$company_id : int

The ID of the company to fetch order form count from

$page : int = 1

The page number of results to fetch

$order : array<string|int, mixed> = ['id' => 'desc']

A key/value pair array of fields to order the results by

$status : string = null

The status of the order forms to fetch:

  • "active" Only active order forms
  • "inactive" Only inactive order forms
  • null All order forms
Return values
array<string|int, mixed>

An array of stdClass objects, each representing an order form

getListCount()

Returns the total number of order forms for the given company

public getListCount(int $company_id[, string $status = null ]) : int
Parameters
$company_id : int

The ID of the company to fetch order form count from

$status : string = null

The status of the order forms to fetch:

  • "active" Only active order forms
  • "inactive" Only inactive order forms
  • null All order forms
Return values
int

The total number of order forms for the given company

getNoticeIntervals()

Retrieves a list of abandoned order reminder intervals in hours

public getNoticeIntervals(int $days) : array<string|int, mixed>
Parameters
$days : int

Number of day intervals to fetch

Return values
array<string|int, mixed>

A list of hours/days and their language

getPriceBreakdown()

Breaks down pricing into different time periods

public getPriceBreakdown(stdClass $pricing[, string $period_breakdown = 'month' ][, bool $formatted = true ]) : mixed
Parameters
$pricing : stdClass

The object representing the pricing

$period_breakdown : string = 'month'

The breakdown period type ("day", "week", "month", "year")

$formatted : bool = true

True to return the price formatted in the given currency, false to return the raw value

Return values
mixed

The price per breakdown period, or false on error

getSavingsPercentage()

Compares two pricings and calculates the percentage of savings

public getSavingsPercentage(stdClass $pricing, stdClass $comparison_pricing) : float
Parameters
$pricing : stdClass

The monthly pricing object (baseline)

$comparison_pricing : stdClass

The pricing object to compare against

Return values
float

The percentage of savings (0 if no savings)

getSupportedTypes()

Returns all supported order type for the given template

public getSupportedTypes(string $template) : array<string|int, mixed>
Parameters
$template : string

The template to fetch all supported order types for

Return values
array<string|int, mixed>

An array of supported order types

getTemplates()

Fetches all templates available to the plugin and the order types they support

public getTemplates() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of key/value pairs where each key is the template directory and each value is an object representing the order template

getTypes()

Fetches all order types available to the plugin

public getTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of key/value pairs where each key is the order type and each value is the order type's name

getVisibilities()

Returns all supported visbilities in key/value pairs

public getVisibilities() : array<string|int, mixed>
Return values
array<string|int, mixed>

Retrieves a list of order forms based on the given search criteria

public search(type $company_id[, array<string|int, mixed> $query = [] ][, array<string|int, mixed> $order = ['order_forms.order' => 'asc'] ]) : array<string|int, mixed>
Parameters
$company_id : type

The ID of the company to fetch order forms for

$query : array<string|int, mixed> = []

Optional criteria to query on:

  • status string The order form status (e.g. 'active', 'inactive')
  • visibility string|array A single visibility or an array of visibilities
  • client_id int The client ID to compare package restrictions to
$order : array<string|int, mixed> = ['order_forms.order' => 'asc']

The order to sort results in

Return values
array<string|int, mixed>

A list of order forms

sortOrderForms()

Save the order forms in the provided order

public sortOrderForms(array<string|int, mixed> $order_form_ids) : mixed
Parameters
$order_form_ids : array<string|int, mixed>

A numerically indexed array of order form IDs

validateAbandonedReminder()

Checks if a value is valid for the abandoned reminder notice

public validateAbandonedReminder(mixed $value) : bool
Parameters
$value : mixed

The value to evaluate

Return values
bool

True if the value is valid

validateClientGroup()

Validates that the given client group exists and is part of the current company

public validateClientGroup(int $client_group_id) : bool
Parameters
$client_group_id : int

The ID of the client group to verify exists

Return values
bool

True if the client group exists and is part of the current company, false otherwise

validatePendingOrdersExists()

Validates whether or not there are any pending orders for the given order form

public validatePendingOrdersExists(int $order_form_id) : bool
Parameters
$order_form_id : int

The order form ID to validate against

Return values
bool

True if there are pending orders, false otherwise

validateTemplate()

Validates that the given order form template supports the given order form type

public validateTemplate(string $template, string $type) : bool
Parameters
$template : string

The order form template

$type : string

The order form type

Return values
bool

True if the template is supported, false otherwise

validateTermsRequired()

Validates whether or not the terms of service URL is required

public validateTermsRequired(string $require_tos, string $tos_url) : bool
Parameters
$require_tos : string

Set to "1" if TOS is required, "0" otherwise

$tos_url : string

The URL to the terms of service

Return values
bool

true if $require_tos is not "1" or if $tos_url is non-empty, false otherwise

validateUnique()

Validates whether or not the given

public validateUnique(string $label[, int $order_form_id = null ]) : bool
Parameters
$label : string

The label to validate

$order_form_id : int = null

The current order form ID (if it already exists) to exclude from the check

Return values
bool

True if the label is unique and does not exist, false otherwise

getCurrencies()

Returns all currencies set for the given form ID

private getCurrencies(int $form_id) : array<string|int, mixed>
Parameters
$form_id : int

The ID of the form to fetch on

Return values
array<string|int, mixed>

An array of stdClass objects containing currencies

getDeleteFormRules()

Returns all validation rules to check when deleting an order form

private getDeleteFormRules() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of validation rules

getFormRules()

Returns all validation rules for adding/editing forms

private getFormRules(array<string|int, mixed> $vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

An array of input key/value pairs

$edit : bool = false

True if this if an edit, false otherwise

Return values
array<string|int, mixed>

An array of validation rules

getGateways()

Returns all gateways set for the given form ID

private getGateways(int $form_id) : array<string|int, mixed>
Parameters
$form_id : int

The ID of the form to fetch on

Return values
array<string|int, mixed>

An array of stdClass objects containing gateway IDs

getGroups()

Returns all order form groups set for the given form ID

private getGroups(int $form_id[, array<string|int, mixed> $query = [] ]) : array<string|int, mixed>
Parameters
$form_id : int

The ID of the form to fetch on

$query : array<string|int, mixed> = []

Optional criteria to query on:

  • client_id int The client ID to compare package restrictions to
  • restrict_groups Whether to restrict package base on client settings
Return values
array<string|int, mixed>

An array of stdClass objects containing order form groups

getMeta()

Returns all meta fields set for the given form ID

private getMeta(int $form_id) : array<string|int, mixed>
Parameters
$form_id : int

The ID of the form to fetch on

Return values
array<string|int, mixed>

An array of stdClass objects representing order form meta fields

getOrderForm()

Returns a partial order form query

private getOrderForm([string $status = null ]) : Record
Parameters
$status : string = null

The status of results to fetch, null to fetch all results

Return values
Record

A partially built order form query

restrictGroups()

Applies filters for the given record

private restrictGroups(PDOStatement $record[, array<string|int, mixed> $query = [] ]) : PDOStatement
Parameters
$record : PDOStatement

A partial record to apply filters to

$query : array<string|int, mixed> = []

Filters to apply

Return values
PDOStatement

A partial record representing a filtered list of order forms

setCurrencies()

Sets currencies for the given order form

private setCurrencies(int $form_id, array<string|int, mixed> $currencies) : mixed
Parameters
$form_id : int

The order form ID to set currencies for

$currencies : array<string|int, mixed>

An array of currency codes to set for the order form

setGateways()

Sets gateways for the given order form

private setGateways(int $form_id, array<string|int, mixed> $gateways) : mixed
Parameters
$form_id : int

The order form ID to set gateways for

$gateways : array<string|int, mixed>

An array of gateway IDs to set for the order form

setGroups()

Sets package groups for the given order form

private setGroups(int $form_id, array<string|int, mixed> $groups) : mixed
Parameters
$form_id : int

The order form ID to set package groups for

$groups : array<string|int, mixed>

An array of package group IDs to set for the order form

setMeta()

Sets meta fields for the given order form

private setMeta(int $form_id, array<string|int, mixed> $meta) : mixed
Parameters
$form_id : int

The order form ID to set meta fields for

$meta : array<string|int, mixed>

An array of key/value pairs

Tags
subpackage

plugins.order.models

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results