Documentation

Discount
in package

Discount

Processes many kinds of discounts - as long as you can express the rules in the terms used here.

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Reto Kohli reto.kohli@comvation.ch

access

public

version
3.0.0
subpackage

module_shop

Table of Contents

Constants

TEXT_NAME_GROUP_ARTICLE  = 'discount_group_article'
TEXT_NAME_GROUP_COUNT  = 'discount_group_name'
Text keys
TEXT_NAME_GROUP_CUSTOMER  = 'discount_group_customer'
TEXT_UNIT_GROUP_COUNT  = 'discount_group_unit'

Properties

$arrArticleGroup  : array<string|int, mixed>
Array of Article groups
$arrCustomerGroup  : array<string|int, mixed>
Array of Customer groups
$arrDiscountCountName  : array<string|int, mixed>
Array of count type discount group names
$arrDiscountCountRate  : array<string|int, mixed>
Array of count type discount group units
$arrDiscountIsCumulative  : array<string|int, mixed>
Tells for each group if different products using this discount group can be summarized to apply the discount.
$arrDiscountRateCustomer  : array<string|int, mixed>
Array of Article/Customer group discount rates

Methods

deleteArticleGroup()  : bool
Delete the article group from the database
deleteCustomerGroup()  : bool
Delete the customer group from the database
deleteDiscountCount()  : bool
Delete the count type discount group seleted by its ID from the database
errorHandler()  : bool
Tries to fix any database problems
flush()  : void
Flushes all static Discount data
getArticleGroupArray()  : array<string|int, mixed>
Returns an array with all the article group names indexed by their ID
getCustomerGroupArray()  : array<string|int, mixed>
Returns an array with all the customer group names indexed by their ID
getCustomerGroupName()  : string
Returns a string with the customer group name for the given ID
getCustomerGroupNameArray()  : array<string|int, mixed>
Returns an array with the customer group names, indexed by ID
getDiscountCountArray()  : array<string|int, mixed>
Returns an array with all the count type discount names indexed by their ID.
getDiscountCountRateArray()  : array<string|int, mixed>
Returns an array with all counts and rates for the count type discount selected by its ID.
getDiscountRateCount()  : float
Determine the product discount rate for the discount group with the given ID and the given count.
getDiscountRateCustomer()  : float
Returns the customer/article type discount rate to be applied for the given group IDs
getDiscountRateCustomerArray()  : array<string|int, mixed>
Returns an array with all the customer/article type discount rates.
getMenuOptionsGroupArticle()  : string
Returns the HTML dropdown menu options with all of the article group names, plus a null option prepended
getMenuOptionsGroupCount()  : string
Returns the HTML dropdown menu options with all of the count type discount names plus a neutral option ("none")
getMenuOptionsGroupCustomer()  : string
Returns the HTML dropdown menu options with all of the customer group names
getUnit()  : string
Returns the unit used for the count type discount group with the given ID
init()  : bool
Initializes all static Discount data
isDiscountCumulative()  : bool
Tells whether a discount group is cumulative for all its products
storeArticleGroup()  : int
Store an article group in the database
storeCustomerGroup()  : int
Store a customer group in the database
storeDiscountCount()  : bool
Store the count type discount settings
storeDiscountCustomer()  : bool
Store the customer/article group discounts in the database.
getItemCountForGroup()  : int
Returns the number of products to calculate the discount

Constants

TEXT_NAME_GROUP_ARTICLE

public mixed TEXT_NAME_GROUP_ARTICLE = 'discount_group_article'

TEXT_NAME_GROUP_COUNT

Text keys

public mixed TEXT_NAME_GROUP_COUNT = 'discount_group_name'

TEXT_NAME_GROUP_CUSTOMER

public mixed TEXT_NAME_GROUP_CUSTOMER = 'discount_group_customer'

TEXT_UNIT_GROUP_COUNT

public mixed TEXT_UNIT_GROUP_COUNT = 'discount_group_unit'

Properties

$arrArticleGroup

Array of Article groups

protected static array<string|int, mixed> $arrArticleGroup = null

$arrCustomerGroup

Array of Customer groups

protected static array<string|int, mixed> $arrCustomerGroup = null

$arrDiscountCountName

Array of count type discount group names

protected static array<string|int, mixed> $arrDiscountCountName = null

$arrDiscountCountRate

Array of count type discount group units

protected static array<string|int, mixed> $arrDiscountCountRate = null

$arrDiscountIsCumulative

Tells for each group if different products using this discount group can be summarized to apply the discount.

protected static array<string|int, mixed> $arrDiscountIsCumulative = null

$arrDiscountRateCustomer

Array of Article/Customer group discount rates

protected static array<string|int, mixed> $arrDiscountRateCustomer = null

Methods

deleteArticleGroup()

Delete the article group from the database

public static deleteArticleGroup(int $group_id) : bool

Backend use only.

Parameters
$group_id : int

The group ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

deleteCustomerGroup()

Delete the customer group from the database

public static deleteCustomerGroup(int $group_id) : bool

Backend use only.

Parameters
$group_id : int

The group ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

deleteDiscountCount()

Delete the count type discount group seleted by its ID from the database

public static deleteDiscountCount(int $group_id) : bool

Backend use only.

Parameters
$group_id : int

The discount group ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

errorHandler()

Tries to fix any database problems

public static errorHandler() : bool
Tags
throws
Update_DatabaseException
Return values
bool

False. Always.

flush()

Flushes all static Discount data

public static flush() : void

getArticleGroupArray()

Returns an array with all the article group names indexed by their ID

public static getArticleGroupArray([int $langId = 0 ]) : array<string|int, mixed>
Parameters
$langId : int = 0

Defaults to FRONTEND_LANG_ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
array<string|int, mixed>

The group name array on success, null otherwise

getCustomerGroupArray()

Returns an array with all the customer group names indexed by their ID

public static getCustomerGroupArray() : array<string|int, mixed>

Backend use only.

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
array<string|int, mixed>

The group name array on success, null otherwise

getCustomerGroupName()

Returns a string with the customer group name for the given ID

public static getCustomerGroupName(int $group_id) : string

Backend use only.

Parameters
$group_id : int

The Customer group ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The group name on success, the string for "none" otherwise

getCustomerGroupNameArray()

Returns an array with the customer group names, indexed by ID

public static getCustomerGroupNameArray() : array<string|int, mixed>

Backend use only. Note that the array returned may be empty.

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
array<string|int, mixed>

The group name array on success, null otherwise

getDiscountCountArray()

Returns an array with all the count type discount names indexed by their ID.

public static getDiscountCountArray() : array<string|int, mixed>

Backend use only.

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
array<string|int, mixed>

The discount name array on success, null otherwise

getDiscountCountRateArray()

Returns an array with all counts and rates for the count type discount selected by its ID.

public static getDiscountCountRateArray(int $group_id) : array<string|int, mixed>

Backend use only. Note that on success, the array returned contains at least one entry, namely that for "no discount".

Parameters
$group_id : int

The count type discount group ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
array<string|int, mixed>

The array with counts and rates on success, null otherwise

getDiscountRateCount()

Determine the product discount rate for the discount group with the given ID and the given count.

public static getDiscountRateCount(int $group_id[, int $count = 1 ]) : float

Frontend use only.

Parameters
$group_id : int

The discount group ID

$count : int = 1

The number of Products

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
float

The discount rate in percent to be applied, if any, 0 (zero) otherwise

getDiscountRateCustomer()

Returns the customer/article type discount rate to be applied for the given group IDs

public static getDiscountRateCustomer(int $groupCustomerId, int $groupArticleId) : float

Frontend use only.

Parameters
$groupCustomerId : int

The customer group ID

$groupArticleId : int

The article group ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
float

The discount rate, if applicable, 0 (zero) otherwise

getDiscountRateCustomerArray()

Returns an array with all the customer/article type discount rates.

public static getDiscountRateCustomerArray() : array<string|int, mixed>

The array has the structure array( customerGroupId => array( articleGroupId => discountRate, ... ), ... );

Tags
static
Return values
array<string|int, mixed>

The discount rate array on success, null otherwise

getMenuOptionsGroupArticle()

Returns the HTML dropdown menu options with all of the article group names, plus a null option prepended

public static getMenuOptionsGroupArticle([int $selectedId = 0 ]) : string

Backend use only.

Parameters
$selectedId : int = 0

The optional preselected ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML dropdown menu options

getMenuOptionsGroupCount()

Returns the HTML dropdown menu options with all of the count type discount names plus a neutral option ("none")

public static getMenuOptionsGroupCount([int $selectedId = 0 ]) : string

Backend use only.

Parameters
$selectedId : int = 0

The optional preselected ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML dropdown menu options on success, false otherwise

getMenuOptionsGroupCustomer()

Returns the HTML dropdown menu options with all of the customer group names

public static getMenuOptionsGroupCustomer([int $selectedId = 0 ]) : string

Backend use only.

Parameters
$selectedId : int = 0

The optional preselected ID

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
string

The HTML dropdown menu options

getUnit()

Returns the unit used for the count type discount group with the given ID

public static getUnit(int $group_id) : string
Parameters
$group_id : int

The count type discount group ID

Return values
string

The unit used for this group on success, the empty string otherwise

init()

Initializes all static Discount data

public static init([int $langId = 0 ]) : bool
Parameters
$langId : int = 0

Defaults to FRONTEND_LANG_ID

Tags
global

\ADOConnection $objDatabase

Return values
bool

True on success, false otherwise

isDiscountCumulative()

Tells whether a discount group is cumulative for all its products

public static isDiscountCumulative(int $group_id) : bool
Parameters
$group_id : int

The discount group ID

Return values
bool

True if $group_id counts order limit accross products

storeArticleGroup()

Store an article group in the database

public static storeArticleGroup(string $groupName[, int $group_id = 0 ][, int $localeId = 0 ]) : int
Parameters
$groupName : string

The group name

$group_id : int = 0

The optional group ID

$localeId : int = 0

Optional locale ID. If not set FRONTEND_LANG_ID will be used.

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
int

The (new) group ID on success, false otherwise

storeCustomerGroup()

Store a customer group in the database

public static storeCustomerGroup(string $groupName[, int $group_id = 0 ][, int $localeId = 0 ]) : int
Parameters
$groupName : string

The group name

$group_id : int = 0

The optional group ID

$localeId : int = 0

Optional locale ID. If not set FRONTEND_LANG_ID will be used.

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
int

The (new) group ID on success, false otherwise

storeDiscountCount()

Store the count type discount settings

public static storeDiscountCount(int $group_id, int $groupType, string $groupName, string $groupUnit, array<string|int, mixed> $arrCount, array<string|int, mixed> $arrRate[, int $localeId = 0 ]) : bool

Backend use only.

Parameters
$group_id : int

The ID of the discount group, if known, or 0 (zero)

$groupType : int

Discount type

$groupName : string

The group name

$groupUnit : string

The group unit

$arrCount : array<string|int, mixed>

The array of minimum counts

$arrRate : array<string|int, mixed>

The array of discount rates, in percent, corresponding to the elements of the count array

$localeId : int = 0

Optional locale ID. If not set FRONTEND_LANG_ID will be used.

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

storeDiscountCustomer()

Store the customer/article group discounts in the database.

public static storeDiscountCustomer(array<string|int, mixed> $arrDiscountRate) : bool

Backend use only. The array argument has the structure array( customerGroupId => array( articleGroupId => discountRate, ... ), ... );

Parameters
$arrDiscountRate : array<string|int, mixed>

The array of discount rates

Tags
static
author

Reto Kohli reto.kohli@comvation.com

Return values
bool

True on success, false otherwise

getItemCountForGroup()

Returns the number of products to calculate the discount

protected static getItemCountForGroup(int $group_id[, int $count = 1 ]) : int
Parameters
$group_id : int

The discount group ID

$count : int = 1

The number of Products

Return values
int

Number of relevant items


        
On this page

Search results