DiscountCouponsManagerBase
Table of Contents
Constants
- COUPON_CHECK_ALREADY_MAX_USED = 0x100
- COUPON_CHECK_BAD_USER_ID = 0x80
- COUPON_CHECK_CORRUPT_DATA = 0x400
- COUPON_CHECK_NO_ACTIVE = 0x2
- COUPON_CHECK_NO_ACTIVE_DISCOUNT = 0x10
- COUPON_CHECK_NOT_APPLIED = 0x800
- COUPON_CHECK_NOT_FOUND = 0x1
- COUPON_CHECK_OK = 0x0
- COUPON_CHECK_RANGE_ACTIVE_FROM = 0x4
- COUPON_CHECK_RANGE_ACTIVE_FROM_DISCOUNT = 0x20
- COUPON_CHECK_RANGE_ACTIVE_TO = 0x8
- COUPON_CHECK_RANGE_ACTIVE_TO_DISCOUNT = 0x40
- COUPON_CHECK_UNKNOWN_TYPE = 0x200
- COUPON_MODE_FULL = 0x2
- COUPON_MODE_SIMPLE = 0x1
- EVENT_ON_BUILD_COUPON_PROVIDES = 'onBuildCouponProviders'
- EVENT_ON_COUPON_ADD = 'onManagerCouponAdd'
- EVENT_ON_COUPON_APPLY = 'onManagerCouponApply'
- EVENT_ON_COUPON_APPLY_PRODUCT = 'onManagerCouponApplyByProduct'
- EVENT_ON_COUPON_DELETE = 'onManagerCouponDelete'
- EVENT_ON_SAVE_APPLIED_COUPONS = 'onManagerSaveApplied'
- MODE_CLIENT = 0x1
- MODE_EXTERNAL = 0x10
- MODE_MANAGER = 0x2
- MODE_ORDER = 0x4
- MODE_SYSTEM = 0x8
- STATUS_APPLYED = 0x4
- STATUS_ENTERED = 0x2
- STATUS_FREEZE = 0x10
- STATUS_NOT_APPLYED = 0x8
- STATUS_NOT_FOUND = 0x1
- STORAGE_CLIENT_COUPONS = 'CATALOG_USER_COUPONS'
- STORAGE_MANAGER_COUPONS = 'CATALOG_MANAGE_COUPONS'
Methods
- add() : bool
- Add coupon in manager.
- clear() : bool
- Clear coupon storage.
- clearApply() : bool
- Clear applied data for coupons.
- clearApplyCoupon() : bool
- Clear applied data for coupon.
- clearByOrder() : bool
- Clear coupon storage for order.
- clearErrors() : void
- Clear errors list.
- delete() : bool
- Delete coupon from manager.
- deleteApplyByProduct() : bool
- Clear applied information for product.
- filterOrderCoupons() : bool
- Returns true if the coupon was used in the order and saved.
- finalApply() : void
- Change status coupons for save.
- freezeCouponStorage() : void
- Disable get coupons for calculate discounts.
- get() : array<string|int, mixed>|bool
- Get coupons list.
- getCheckCodeList() : array<string|int, mixed>
- Returns check code list.
- getCheckCodeMessage() : string|null
- Returns description of check code.
- getData() : array<string|int, mixed>|false
- Returns information about coupon.
- getEnteredCoupon() : bool|array<string|int, mixed>
- Returns entered coupon data.
- getErrors() : array<string|int, mixed>
- Returns error list.
- getForApply() : array<string|int, mixed>|bool
- Get coupons list for apply.
- getOrderedCoupons() : array<string|int, mixed>
- Returns coupons for current order.
- getOrderId() : null|int
- Returns order id, if current use mode self::MODE_ORDER.
- getRegistryType() : string
- getStatusList() : array<string|int, mixed>
- Returns coupon status list.
- getUseMode() : int
- Returns use mode.
- getUserId() : null|int
- Returns user id.
- init() : void
- Initialization coupon manager.
- initUseMode() : void
- Init use mode and user id.
- isEntered() : bool
- Returns true, if coupons were are entered.
- isExist() : array<string|int, mixed>|bool
- Checks if a coupon exists.
- isFrozenCouponStorage() : bool
- Returns true, if disallow get coupons for calculate discounts.
- isSuccess() : bool
- Returns a sign of success.
- isUsedOrderCouponsForApply() : bool
- Returns use ordered coupons for apply.
- load() : void
- Load coupons for existing order.
- logout() : void
- Clear coupons storage with logout from public.
- migrateStorage() : void
- Change coupons owner in manager or order mode.
- reInit() : void
- Unconditional reinitialization coupon manager.
- saveApplied() : Result
- Save applied coupons.
- setApply() : bool
- Set applied information for basket.
- setApplyByProduct() : bool
- Set applied information for product.
- unFreezeCouponStorage() : void
- Enable get coupons for calculate discounts.
- usedByClient() : bool
- Verifies that the client mode being used.
- usedByExternal() : bool
- Verifies that the external order mode being used.
- usedByManager() : bool
- Verifies that the manager mode being used.
- useSavedCouponsForApply() : void
- Set use ordered coupons for apply.
- verifyApplied() : Result
- Verifies the current status of new applied coupons. Used before order save.
Constants
COUPON_CHECK_ALREADY_MAX_USED
public
mixed
COUPON_CHECK_ALREADY_MAX_USED
= 0x100
COUPON_CHECK_BAD_USER_ID
public
mixed
COUPON_CHECK_BAD_USER_ID
= 0x80
COUPON_CHECK_CORRUPT_DATA
public
mixed
COUPON_CHECK_CORRUPT_DATA
= 0x400
COUPON_CHECK_NO_ACTIVE
public
mixed
COUPON_CHECK_NO_ACTIVE
= 0x2
COUPON_CHECK_NO_ACTIVE_DISCOUNT
public
mixed
COUPON_CHECK_NO_ACTIVE_DISCOUNT
= 0x10
COUPON_CHECK_NOT_APPLIED
public
mixed
COUPON_CHECK_NOT_APPLIED
= 0x800
COUPON_CHECK_NOT_FOUND
public
mixed
COUPON_CHECK_NOT_FOUND
= 0x1
COUPON_CHECK_OK
public
mixed
COUPON_CHECK_OK
= 0x0
COUPON_CHECK_RANGE_ACTIVE_FROM
public
mixed
COUPON_CHECK_RANGE_ACTIVE_FROM
= 0x4
COUPON_CHECK_RANGE_ACTIVE_FROM_DISCOUNT
public
mixed
COUPON_CHECK_RANGE_ACTIVE_FROM_DISCOUNT
= 0x20
COUPON_CHECK_RANGE_ACTIVE_TO
public
mixed
COUPON_CHECK_RANGE_ACTIVE_TO
= 0x8
COUPON_CHECK_RANGE_ACTIVE_TO_DISCOUNT
public
mixed
COUPON_CHECK_RANGE_ACTIVE_TO_DISCOUNT
= 0x40
COUPON_CHECK_UNKNOWN_TYPE
public
mixed
COUPON_CHECK_UNKNOWN_TYPE
= 0x200
COUPON_MODE_FULL
public
mixed
COUPON_MODE_FULL
= 0x2
COUPON_MODE_SIMPLE
public
mixed
COUPON_MODE_SIMPLE
= 0x1
EVENT_ON_BUILD_COUPON_PROVIDES
public
mixed
EVENT_ON_BUILD_COUPON_PROVIDES
= 'onBuildCouponProviders'
EVENT_ON_COUPON_ADD
public
mixed
EVENT_ON_COUPON_ADD
= 'onManagerCouponAdd'
EVENT_ON_COUPON_APPLY
public
mixed
EVENT_ON_COUPON_APPLY
= 'onManagerCouponApply'
EVENT_ON_COUPON_APPLY_PRODUCT
public
mixed
EVENT_ON_COUPON_APPLY_PRODUCT
= 'onManagerCouponApplyByProduct'
EVENT_ON_COUPON_DELETE
public
mixed
EVENT_ON_COUPON_DELETE
= 'onManagerCouponDelete'
EVENT_ON_SAVE_APPLIED_COUPONS
public
mixed
EVENT_ON_SAVE_APPLIED_COUPONS
= 'onManagerSaveApplied'
MODE_CLIENT
public
mixed
MODE_CLIENT
= 0x1
MODE_EXTERNAL
public
mixed
MODE_EXTERNAL
= 0x10
MODE_MANAGER
public
mixed
MODE_MANAGER
= 0x2
MODE_ORDER
public
mixed
MODE_ORDER
= 0x4
MODE_SYSTEM
public
mixed
MODE_SYSTEM
= 0x8
STATUS_APPLYED
public
mixed
STATUS_APPLYED
= 0x4
STATUS_ENTERED
public
mixed
STATUS_ENTERED
= 0x2
STATUS_FREEZE
public
mixed
STATUS_FREEZE
= 0x10
STATUS_NOT_APPLYED
public
mixed
STATUS_NOT_APPLYED
= 0x8
STATUS_NOT_FOUND
public
mixed
STATUS_NOT_FOUND
= 0x1
STORAGE_CLIENT_COUPONS
public
mixed
STORAGE_CLIENT_COUPONS
= 'CATALOG_USER_COUPONS'
STORAGE_MANAGER_COUPONS
public
mixed
STORAGE_MANAGER_COUPONS
= 'CATALOG_MANAGE_COUPONS'
Methods
add()
Add coupon in manager.
public
static add(string $coupon) : bool
Parameters
- $coupon : string
-
Added coupon.
Return values
boolclear()
Clear coupon storage.
public
static clear([bool $clearStorage = false ]) : bool
Parameters
- $clearStorage : bool = false
-
Clear coupon session storage.
Return values
boolclearApply()
Clear applied data for coupons.
public
static clearApply([bool $all = true ]) : bool
Parameters
- $all : bool = true
-
Clear for coupons or not saved.
Return values
boolclearApplyCoupon()
Clear applied data for coupon.
public
static clearApplyCoupon(string $coupon) : bool
Parameters
- $coupon : string
-
Coupon.
Return values
boolclearByOrder()
Clear coupon storage for order.
public
static clearByOrder(int $order) : bool
Parameters
- $order : int
-
Order id.
Return values
boolclearErrors()
Clear errors list.
public
static clearErrors() : void
delete()
Delete coupon from manager.
public
static delete(string $coupon) : bool
Parameters
- $coupon : string
-
Deleted coupon.
Return values
booldeleteApplyByProduct()
Clear applied information for product.
public
static deleteApplyByProduct(array<string|int, mixed> $product) : bool
Parameters
- $product : array<string|int, mixed>
-
Product description.
Return values
boolfilterOrderCoupons()
Returns true if the coupon was used in the order and saved.
public
static filterOrderCoupons(array<string|int, mixed> $coupon) : bool
Parameters
- $coupon : array<string|int, mixed>
-
Coupon data.
Return values
boolfinalApply()
Change status coupons for save.
public
static finalApply() : void
freezeCouponStorage()
Disable get coupons for calculate discounts.
public
static freezeCouponStorage() : void
get()
Get coupons list.
public
static get([bool $extMode = true ][, array<string|int, mixed> $filter = [] ][, bool $show = false ][, bool $final = false ]) : array<string|int, mixed>|bool
Parameters
- $extMode : bool = true
-
Get full information or coupons only.
- $filter : array<string|int, mixed> = []
-
Coupons filter.
- $show : bool = false
-
Get for show or apply.
- $final : bool = false
-
Change status ENTERED to NOT_APPLIED.
Return values
array<string|int, mixed>|boolgetCheckCodeList()
Returns check code list.
public
static getCheckCodeList([bool $extendedMode = false ]) : array<string|int, mixed>
Parameters
- $extendedMode : bool = false
-
Get codes or codes with description.
Return values
array<string|int, mixed>getCheckCodeMessage()
Returns description of check code.
public
static getCheckCodeMessage(int $code) : string|null
Parameters
- $code : int
-
Code value.
Return values
string|nullgetData()
Returns information about coupon.
public
static getData(string $coupon[, bool $checkCoupon = true ]) : array<string|int, mixed>|false
Parameters
- $coupon : string
-
Coupon for search.
- $checkCoupon : bool = true
-
Check coupon data.
Return values
array<string|int, mixed>|falsegetEnteredCoupon()
Returns entered coupon data.
public
static getEnteredCoupon(string $coupon[, bool $clearData = false ]) : bool|array<string|int, mixed>
Parameters
- $coupon : string
-
Coupon code.
- $clearData : bool = false
-
Clear data for save order coupon.
Return values
bool|array<string|int, mixed>getErrors()
Returns error list.
public
static getErrors() : array<string|int, mixed>
Return values
array<string|int, mixed>getForApply()
Get coupons list for apply.
public
static getForApply(array<string|int, mixed> $filter[, array<string|int, mixed> $product = [] ][, bool $uniqueDiscount = false ]) : array<string|int, mixed>|bool
Parameters
- $filter : array<string|int, mixed>
-
Coupons filter.
- $product : array<string|int, mixed> = []
-
Product description.
- $uniqueDiscount : bool = false
-
Get one coupon for discount.
Return values
array<string|int, mixed>|boolgetOrderedCoupons()
Returns coupons for current order.
public
static getOrderedCoupons([bool $extMode = true ][, array<string|int, mixed> $filter = [] ]) : array<string|int, mixed>
Parameters
- $extMode : bool = true
-
Get full information or coupons only.
- $filter : array<string|int, mixed> = []
-
Coupons filter.
Return values
array<string|int, mixed>getOrderId()
Returns order id, if current use mode self::MODE_ORDER.
public
static getOrderId() : null|int
Return values
null|intgetRegistryType()
public
static getRegistryType() : string
Tags
Return values
stringgetStatusList()
Returns coupon status list.
public
static getStatusList([bool $extendedMode = false ]) : array<string|int, mixed>
Parameters
- $extendedMode : bool = false
-
Get status Ids or Ids with description.
Return values
array<string|int, mixed>getUseMode()
Returns use mode.
public
static getUseMode() : int
Return values
intgetUserId()
Returns user id.
public
static getUserId() : null|int
Return values
null|intinit()
Initialization coupon manager.
public
static init([int $mode = \self::MODE_CLIENT ][, array<string|int, mixed> $params = [] ][, bool $clearStorage = false ]) : void
Parameters
- $mode : int = \self::MODE_CLIENT
-
Discount manager mode.
- $params : array<string|int, mixed> = []
-
Initial params (userId, orderId, oldUserId) keys are case-sensitive:
- int userId Order owner (for MODE_MANAGER or MODE_ORDER only)
- int orderId Edit order id (for MODE_ORDER only(!))
- int oldUserId Old order owner (for MODE_MANAGER or MODE_ORDER only)
- $clearStorage : bool = false
-
Clear coupon session storage.
initUseMode()
Init use mode and user id.
public
static initUseMode([int $mode = \self::MODE_CLIENT ][, array<string|int, mixed> $params = [] ]) : void
Parameters
- $mode : int = \self::MODE_CLIENT
-
Discount manager mode.
- $params : array<string|int, mixed> = []
-
Initial params (userId, orderId, oldUserId) keys are case-sensitive:
- int userId Order owner (for MODE_MANAGER or MODE_ORDER only)
- int orderId Edit order id (for MODE_ORDER only(!))
- int oldUserId Old order owner (for MODE_MANAGER or MODE_ORDER only)
isEntered()
Returns true, if coupons were are entered.
public
static isEntered() : bool
Return values
boolisExist()
Checks if a coupon exists.
public
static isExist(string $coupon) : array<string|int, mixed>|bool
Parameters
- $coupon : string
-
Coupon for check.
Return values
array<string|int, mixed>|boolisFrozenCouponStorage()
Returns true, if disallow get coupons for calculate discounts.
public
static isFrozenCouponStorage() : bool
Return values
boolisSuccess()
Returns a sign of success.
public
static isSuccess() : bool
Return values
boolisUsedOrderCouponsForApply()
Returns use ordered coupons for apply.
public
static isUsedOrderCouponsForApply() : bool
Return values
boolload()
Load coupons for existing order.
public
static load() : void
logout()
Clear coupons storage with logout from public.
public
static logout() : void
migrateStorage()
Change coupons owner in manager or order mode.
public
static migrateStorage(int $oldUser) : void
Parameters
- $oldUser : int
-
Old user id.
reInit()
Unconditional reinitialization coupon manager.
public
static reInit([int $mode = \self::MODE_CLIENT ][, array<string|int, mixed> $params = [] ][, bool $clearStorage = false ]) : void
Parameters
- $mode : int = \self::MODE_CLIENT
-
Discount manager mode.
- $params : array<string|int, mixed> = []
-
Initial params (userId, orderId, oldUserId) keys are case-sensitive:
- int userId Order owner (for MODE_MANAGER or MODE_ORDER only)
- int orderId Edit order id (for MODE_ORDER only(!))
- int oldUserId Old order owner (for MODE_MANAGER or MODE_ORDER only)
- $clearStorage : bool = false
-
Clear coupon session storage.
saveApplied()
Save applied coupons.
public
static saveApplied() : Result
Return values
ResultsetApply()
Set applied information for basket.
public
static setApply(string $coupon, array<string|int, mixed> $data) : bool
Parameters
- $coupon : string
-
Coupon.
- $data : array<string|int, mixed>
-
Apply data (basket, delivery).
Return values
boolsetApplyByProduct()
Set applied information for product.
public
static setApplyByProduct(array<string|int, mixed> $product, array<string|int, mixed> $couponsList[, bool $oldMode = false ]) : bool
Parameters
- $product : array<string|int, mixed>
-
Product description.
- $couponsList : array<string|int, mixed>
-
Coupons for product.
- $oldMode : bool = false
-
Compatibility mode with old custom providers.
Return values
boolunFreezeCouponStorage()
Enable get coupons for calculate discounts.
public
static unFreezeCouponStorage() : void
usedByClient()
Verifies that the client mode being used.
public
static usedByClient() : bool
Return values
boolusedByExternal()
Verifies that the external order mode being used.
public
static usedByExternal() : bool
Return values
boolusedByManager()
Verifies that the manager mode being used.
public
static usedByManager() : bool
Return values
booluseSavedCouponsForApply()
Set use ordered coupons for apply.
public
static useSavedCouponsForApply(bool $state) : void
Parameters
- $state : bool
-
Use state.
verifyApplied()
Verifies the current status of new applied coupons. Used before order save.
public
static verifyApplied() : Result