Actions
Table of Contents
Constants
- ACTION_TYPE_DISCOUNT = 'D'
- ACTION_TYPE_EXTRA = 'E'
- APPLY_COUNTER_START = -1
- APPLY_RESULT_MODE_COUNTER = 0x1
- APPLY_RESULT_MODE_DESCR = 0x2
- APPLY_RESULT_MODE_SIMPLE = 0x4
- BASKET_APPLIED_FIELD = 'DISCOUNT_APPLIED'
- GIFT_SELECT_TYPE_ALL = 'all'
- GIFT_SELECT_TYPE_ONE = 'one'
- MODE_CALCULATE = 0x1
- MODE_MANUAL = 0x2
- MODE_MIXED = 0x4
- PERCENT_FROM_BASE_PRICE = 0x2
- PERCENT_FROM_CURRENT_PRICE = 0x1
- RESULT_ENTITY_BASKET = 0x1
- RESULT_ENTITY_DELIVERY = 0x2
- RESULT_ENTITY_ORDER = 0x4
- VALUE_EPS = 1.0E-5
- VALUE_TYPE_CLOSEOUT = 'C'
- VALUE_TYPE_FIX = 'F'
- VALUE_TYPE_PERCENT = 'P'
- VALUE_TYPE_SUMM = 'S'
Methods
- applyCumulativeToBasket() : void
- Cumulative action.
- applySimpleGift() : void
- Simple gift action.
- applyToBasket() : void
- Basket action.
- applyToDelivery() : void
- Delivery action.
- checkUseMode() : bool
- Check current use actions mode.
- clearAction() : void
- Clear actions description and result.
- clearApplyCounter() : void
- Clear apply counter.
- clearEntityActionResult() : void
- disableBasketFilter() : void
- Disable basket filter for mixed apply mode.
- enableBasketFilter() : void
- Enable basket filter for mixed apply mode.
- fillCompatibleFields() : void
- Fill compatible fields for old public api.
- filterBasketForAction() : bool
- Basket filter.
- getActionConfiguration() : mixed
- getActionDescription() : array<string|int, mixed>
- Return all actions description.
- getActionResult() : array<string|int, mixed>
- Return all actions results.
- getActionStoredData() : array<string|int, mixed>|null
- Return stored action.
- getApplyCounter() : int
- Return current apply counter.
- getApplyResultMode() : int
- Return apply result format mode.
- getBasketForApply() : mixed
- Return basket item for action apply.
- getCurrency() : string
- Return calculate currency.
- getPercentByValue() : float
- Return percent value.
- getPercentMode() : int
- Return calculate mode for percent discount.
- getStoredData() : array<string|int, mixed>
- Return stored data after discount calculation.
- getUseMode() : int
- Returns current use actions mode.
- increaseApplyCounter() : void
- Increment current apply counter. Use BEFORE discount action apply.
- isCalculateMode() : bool
- Check calculate mode.
- isManualMode() : bool
- Check manual mode.
- isMixedMode() : bool
- Check mixed mode.
- percentToValue() : float
- Calculate percent price.
- roundValue() : float
- Rounded value with sale rules.
- roundZeroValue() : float|int
- Check for zero value.
- setActionDescription() : void
- Save action description.
- setActionResult() : void
- Save result.
- setActionStoredData() : void
- Fill action data to store.
- setApplyResult() : void
- Set apply result list.
- setApplyResultMode() : void
- Set apply result format mode.
- setStoredData() : void
- Fill data to store for discount.
- setUseMode() : void
- Set use actions mode.
- usedBasketFilter() : bool
- Return is enabled basket filter mixed apply mode.
Constants
ACTION_TYPE_DISCOUNT
public
mixed
ACTION_TYPE_DISCOUNT
= 'D'
ACTION_TYPE_EXTRA
public
mixed
ACTION_TYPE_EXTRA
= 'E'
APPLY_COUNTER_START
public
mixed
APPLY_COUNTER_START
= -1
APPLY_RESULT_MODE_COUNTER
public
mixed
APPLY_RESULT_MODE_COUNTER
= 0x1
APPLY_RESULT_MODE_DESCR
public
mixed
APPLY_RESULT_MODE_DESCR
= 0x2
APPLY_RESULT_MODE_SIMPLE
public
mixed
APPLY_RESULT_MODE_SIMPLE
= 0x4
BASKET_APPLIED_FIELD
public
mixed
BASKET_APPLIED_FIELD
= 'DISCOUNT_APPLIED'
GIFT_SELECT_TYPE_ALL
public
mixed
GIFT_SELECT_TYPE_ALL
= 'all'
GIFT_SELECT_TYPE_ONE
public
mixed
GIFT_SELECT_TYPE_ONE
= 'one'
MODE_CALCULATE
public
mixed
MODE_CALCULATE
= 0x1
MODE_MANUAL
public
mixed
MODE_MANUAL
= 0x2
MODE_MIXED
public
mixed
MODE_MIXED
= 0x4
PERCENT_FROM_BASE_PRICE
public
mixed
PERCENT_FROM_BASE_PRICE
= 0x2
PERCENT_FROM_CURRENT_PRICE
public
mixed
PERCENT_FROM_CURRENT_PRICE
= 0x1
RESULT_ENTITY_BASKET
public
mixed
RESULT_ENTITY_BASKET
= 0x1
RESULT_ENTITY_DELIVERY
public
mixed
RESULT_ENTITY_DELIVERY
= 0x2
RESULT_ENTITY_ORDER
public
mixed
RESULT_ENTITY_ORDER
= 0x4
VALUE_EPS
public
mixed
VALUE_EPS
= 1.0E-5
VALUE_TYPE_CLOSEOUT
public
mixed
VALUE_TYPE_CLOSEOUT
= 'C'
VALUE_TYPE_FIX
public
mixed
VALUE_TYPE_FIX
= 'F'
VALUE_TYPE_PERCENT
public
mixed
VALUE_TYPE_PERCENT
= 'P'
VALUE_TYPE_SUMM
public
mixed
VALUE_TYPE_SUMM
= 'S'
Methods
applyCumulativeToBasket()
Cumulative action.
public
static applyCumulativeToBasket(array<string|int, mixed> &$order, array<string|int, mixed> $ranges[, array<string|int, mixed> $configuration = array() ][, callable|null $filter = null ]) : void
Parameters
- $order : array<string|int, mixed>
-
Order data.
- $ranges : array<string|int, mixed>
- $configuration : array<string|int, mixed> = array()
- $filter : callable|null = null
Tags
applySimpleGift()
Simple gift action.
public
static applySimpleGift(array<string|int, mixed> &$order, callable $filter) : void
Parameters
- $order : array<string|int, mixed>
-
Order data.
- $filter : callable
-
Filter.
Tags
applyToBasket()
Basket action.
public
static applyToBasket(array<string|int, mixed> &$order, array<string|int, mixed> $action, callable $filter) : void
Parameters
- $order : array<string|int, mixed>
-
Order data.
- $action : array<string|int, mixed>
-
Action detail keys are case sensitive:
- float|int VALUE Discount value.
- char UNIT Discount type.
- string CURRENCY Currency discount (optional).
- char MAX_BOUND Max bound (optional).
- $filter : callable
-
Filter for basket items.
applyToDelivery()
Delivery action.
public
static applyToDelivery(array<string|int, mixed> &$order, array<string|int, mixed> $action) : void
Parameters
- $order : array<string|int, mixed>
-
Order data.
- $action : array<string|int, mixed>
-
Action detail keys are case sensitive:
- float|int VALUE Discount value.
- char UNIT Discount type.
- string CURRENCY Currency discount (optional).
- char MAX_BOUND Max bound.
checkUseMode()
Check current use actions mode.
public
static checkUseMode(array<string|int, mixed> $list) : bool
Parameters
- $list : array<string|int, mixed>
Return values
boolclearAction()
Clear actions description and result.
public
static clearAction() : void
clearApplyCounter()
Clear apply counter.
public
static clearApplyCounter() : void
clearEntityActionResult()
public
static clearEntityActionResult(int $entity[, array<string|int, mixed> $entityParams = array() ]) : void
Parameters
- $entity : int
-
Entity id.
- $entityParams : array<string|int, mixed> = array()
-
Entity params (optional).
disableBasketFilter()
Disable basket filter for mixed apply mode.
public
static disableBasketFilter() : void
enableBasketFilter()
Enable basket filter for mixed apply mode.
public
static enableBasketFilter() : void
fillCompatibleFields()
Fill compatible fields for old public api.
public
static fillCompatibleFields(array<string|int, mixed> &$order) : void
Parameters
- $order : array<string|int, mixed>
-
Order data.
filterBasketForAction()
Basket filter.
public
static filterBasketForAction(array<string|int, mixed> $item) : bool
Parameters
- $item : array<string|int, mixed>
-
Basket item.
Return values
boolgetActionConfiguration()
public
static getActionConfiguration(array<string|int, mixed> $discount) : mixed
Parameters
- $discount : array<string|int, mixed>
getActionDescription()
Return all actions description.
public
static getActionDescription() : array<string|int, mixed>
Return values
array<string|int, mixed>getActionResult()
Return all actions results.
public
static getActionResult() : array<string|int, mixed>
Return values
array<string|int, mixed>getActionStoredData()
Return stored action.
public
static getActionStoredData() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetApplyCounter()
Return current apply counter.
public
static getApplyCounter() : int
Return values
intgetApplyResultMode()
Return apply result format mode.
public
static getApplyResultMode() : int
Return values
intgetBasketForApply()
Return basket item for action apply.
public
static getBasketForApply(array<string|int, mixed> $basket, mixed $filter[, array<string|int, mixed> $action = array() ]) : mixed
Parameters
- $basket : array<string|int, mixed>
-
Basket.
- $filter : mixed
-
Filter.
- $action : array<string|int, mixed> = array()
-
Prepare data.
getCurrency()
Return calculate currency.
public
static getCurrency() : string
Return values
stringgetPercentByValue()
Return percent value.
public
static getPercentByValue(array<string|int, mixed> $basket, int|float $value) : float
Parameters
- $basket : array<string|int, mixed>
-
Basket.
- $value : int|float
-
Value.
Return values
floatgetPercentMode()
Return calculate mode for percent discount.
public
static getPercentMode() : int
Return values
intgetStoredData()
Return stored data after discount calculation.
public
static getStoredData() : array<string|int, mixed>
Return values
array<string|int, mixed>getUseMode()
Returns current use actions mode.
public
static getUseMode() : int
Return values
intincreaseApplyCounter()
Increment current apply counter. Use BEFORE discount action apply.
public
static increaseApplyCounter() : void
isCalculateMode()
Check calculate mode.
public
static isCalculateMode() : bool
Return values
boolisManualMode()
Check manual mode.
public
static isManualMode() : bool
Return values
boolisMixedMode()
Check mixed mode.
public
static isMixedMode() : bool
Return values
boolpercentToValue()
Calculate percent price.
public
static percentToValue(array<string|int, mixed> $basketRow, float $percent) : float
Parameters
- $basketRow : array<string|int, mixed>
-
Basket item.
- $percent : float
-
Percent value.
Return values
floatroundValue()
Rounded value with sale rules.
public
static roundValue(float|int $value, string $currency) : float
Parameters
- $value : float|int
-
Value.
- $currency : string
-
Currency.
Return values
floatroundZeroValue()
Check for zero value.
public
static roundZeroValue(float|int $value) : float|int
Parameters
- $value : float|int
-
Price or discount value.
Return values
float|intsetActionDescription()
Save action description.
public
static setActionDescription(int $type, array<string|int, mixed> $description) : void
Parameters
- $type : int
-
Action object type.
- $description : array<string|int, mixed>
-
Description.
setActionResult()
Save result.
public
static setActionResult(int $entity, array<string|int, mixed> $actionResult) : void
Parameters
- $entity : int
-
Action object type.
- $actionResult : array<string|int, mixed>
-
Result description.
setActionStoredData()
Fill action data to store.
public
static setActionStoredData(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
-
Action data to store.
setApplyResult()
Set apply result list.
public
static setApplyResult(array<string|int, mixed> $applyResult) : void
Parameters
- $applyResult : array<string|int, mixed>
-
Apply data.
setApplyResultMode()
Set apply result format mode.
public
static setApplyResultMode(int $mode) : void
Parameters
- $mode : int
-
Apply result mode.
setStoredData()
Fill data to store for discount.
public
static setStoredData(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
-
Data.
setUseMode()
Set use actions mode.
public
static setUseMode(int $mode[, array<string|int, mixed> $config = array() ]) : void
Parameters
- $mode : int
-
Use mode.
- $config : array<string|int, mixed> = array()
-
Config.
usedBasketFilter()
Return is enabled basket filter mixed apply mode.
public
static usedBasketFilter() : bool