Bitrix API

DiscountCouponTable extends DataManager

Class DiscountCouponTable

Fields:

  • ID int mandatory
  • DISCOUNT_ID int mandatory
  • ACTIVE bool optional default 'Y'
  • ACTIVE_FROM datetime optional
  • ACTIVE_TO datetime optional
  • COUPON string(32) mandatory
  • TYPE int mandatory
  • MAX_USE int mandatory
  • USE_COUNT int mandatory
  • USER_ID int mandatory
  • DATE_APPLY datetime optional
  • TIMESTAMP_X datetime optional
  • MODIFIED_BY int optional
  • DATE_CREATE datetime optional
  • CREATED_BY int optional
  • DESCRIPTION text optional
  • CREATED_BY_USER reference to [](\Bitrix\Main\UserTable)
  • MODIFIED_BY_USER reference to [](\Bitrix\Main\UserTable)
  • DISCOUNT reference to [](\Bitrix\Sale\Internals\DiscountTable)

Table of Contents

Constants

EVENT_ON_ADD  = "OnAdd"
EVENT_ON_AFTER_ADD  = "OnAfterAdd"
EVENT_ON_AFTER_DELETE  = "OnAfterDelete"
EVENT_ON_AFTER_DELETE_DISCOUNT  = 'onAfterDeleteDiscountCoupons'
EVENT_ON_AFTER_UPDATE  = "OnAfterUpdate"
EVENT_ON_BEFORE_ADD  = "OnBeforeAdd"
EVENT_ON_BEFORE_DELETE  = "OnBeforeDelete"
EVENT_ON_BEFORE_UPDATE  = "OnBeforeUpdate"
EVENT_ON_DELETE  = "OnDelete"
EVENT_ON_GENERATE_COUPON  = 'onGenerateCoupon'
EVENT_ON_UPDATE  = "OnUpdate"
TYPE_ARCHIVED  = 0x8
TYPE_BASKET_ROW  = 0x1
TYPE_MULTI_ORDER  = 0x4
TYPE_ONE_ORDER  = 0x2
TYPE_UNKNOWN  = 0x0

Methods

add()  : AddResult
Adds row to entity table
addMulti()  : AddResult
Adds several rows to entity table.
addPacket()  : Result
Create one and more coupons for discount.
checkCoupon()  : bool|string
Check coupon - unique and exist.
checkDiscountId()  : bool|string
Check discount id.
checkFields()  : mixed
Checks the data fields before saving to DB. Result stores in the $result object
checkPacket()  : Result
Check data for create one or more coupons.
checkType()  : bool|string
Check coupon type.
cleanCache()  : void
Cleans the tablet cache after data modifications.
clearDiscountCheckList()  : void
Clear discount list for update use coupons flag.
createCollection()  : EO_DiscountCoupon_Collection
createObject()  : EO_DiscountCoupon
cryptoEnabled()  : bool
Returns true if crypto is enabled for a field.
delete()  : DeleteResult
Deletes row in entity table by primary key
deleteByDiscount()  : void
Delete all coupons for discount.
disableCheckCouponsUse()  : void
Disable checking use coupons for discount before multiuse add/update/delete.
enableCheckCouponsUse()  : void
Enable checking use coupons for discount after multiuse add/update/delete.
enableCrypto()  : mixed
Sets a flag indicating crypto support for a field.
generateCoupon()  : string
Create coupon code.
getById()  : EO_DiscountCoupon_Result
Returns selection by entity's primary key
getByPrimary()  : EO_DiscountCoupon_Result
Returns selection by entity's primary key and optional parameters for getList()
getCollectionClass()  : string|Collection
Returns class of Object collection for current entity.
getCollectionClassName()  : string
Returns class name (without namespace) of Object collection for current entity.
getCollectionParentClass()  : Collection|string
getConnectionName()  : string
Returns connection name for entity
getCount()  : int
Performs COUNT query on entity and returns the result.
getCouponTypes()  : array<string|int, mixed>
Returns coupon types list.
getEntity()  : EO_DiscountCoupon_Entity
Returns entity object
getEntityClass()  : Entity|string
getList()  : EO_DiscountCoupon_Result
Executes the query and returns selection by parameters of the query. This function is an alias to the Query object functions
getMap()  : array<string|int, mixed>
Returns entity map definition.
getObjectClass()  : string|EntityObject
Returns class of Object for current entity.
getObjectClassName()  : string
Returns class name (without namespace) of Object for current entity.
getObjectParentClass()  : EntityObject|string
getQueryClass()  : Query|string
getRow()  : array<string|int, mixed>|null
Returns one row (or null) by parameters for getList()
getRowById()  : array<string|int, mixed>|null
Returns one row (or null) by entity's primary key
getTableName()  : string
Returns DB table name for entity.
getTitle()  : string|null
getUfId()  : mixed
isCacheable()  : bool
You can disable cache for the tablet completely.
isCheckedCouponsUse()  : bool
Returns current checking use coupons mode.
isUtm()  : mixed
isUts()  : mixed
isValidCouponType()  : bool
Check valid coupon type.
onAdd()  : mixed
onAfterAdd()  : void
Default onAfterAdd handler. Absolutely necessary.
onAfterDelete()  : void
Default onAfterDelete handler. Absolutely necessary.
onAfterUpdate()  : void
Default onAfterUpdate handler. Absolutely necessary.
onBeforeAdd()  : EventResult
Default onBeforeAdd handler. Absolutely necessary.
onBeforeDelete()  : mixed
onBeforeUpdate()  : EventResult
Default onBeforeUpdate handler. Absolutely necessary.
onDelete()  : void
Default onDelete handler. Absolutely necessary.
onUpdate()  : void
Default onUpdate handler. Absolutely necessary.
postInitialize()  : null
prepareCouponData()  : Result
Prepare coupon data. Only for admin list pages.
query()  : EO_DiscountCoupon_Query
Creates and returns the Query object for the entity
saveApplied()  : array<string|int, mixed>|bool
Save coupons applyed info.
setCurrentDeletingObject()  : void
setDefaultScope()  : Query
setDiscountCheckList()  : void
Fill discount list for update use coupons flag.
unsetEntity()  : mixed
update()  : UpdateResult
Updates row in entity table by primary key
updateMulti()  : UpdateResult
updateUseCoupons()  : void
Update use coupon flag for discount list.
validateCoupon()  : array<string|int, mixed>
Returns validators for COUPON field.
validateDiscountId()  : array<string|int, mixed>
Returns validators for DISCOUNT_ID field.
validateType()  : array<string|int, mixed>
Returns validators for TYPE field.
wakeUpCollection()  : EO_DiscountCoupon_Collection
wakeUpObject()  : EO_DiscountCoupon

Constants

EVENT_ON_AFTER_ADD

public mixed EVENT_ON_AFTER_ADD = "OnAfterAdd"

EVENT_ON_AFTER_DELETE

public mixed EVENT_ON_AFTER_DELETE = "OnAfterDelete"

EVENT_ON_AFTER_DELETE_DISCOUNT

public mixed EVENT_ON_AFTER_DELETE_DISCOUNT = 'onAfterDeleteDiscountCoupons'

EVENT_ON_AFTER_UPDATE

public mixed EVENT_ON_AFTER_UPDATE = "OnAfterUpdate"

EVENT_ON_BEFORE_ADD

public mixed EVENT_ON_BEFORE_ADD = "OnBeforeAdd"

EVENT_ON_BEFORE_DELETE

public mixed EVENT_ON_BEFORE_DELETE = "OnBeforeDelete"

EVENT_ON_BEFORE_UPDATE

public mixed EVENT_ON_BEFORE_UPDATE = "OnBeforeUpdate"

EVENT_ON_DELETE

public mixed EVENT_ON_DELETE = "OnDelete"

EVENT_ON_GENERATE_COUPON

public mixed EVENT_ON_GENERATE_COUPON = 'onGenerateCoupon'

EVENT_ON_UPDATE

public mixed EVENT_ON_UPDATE = "OnUpdate"

Methods

add()

Adds row to entity table

public static add(array<string|int, mixed> $data) : AddResult
Parameters
$data : array<string|int, mixed>

An array with fields like array( "fields" => array( "FIELD1" => "value1", "FIELD2" => "value2", ), "auth_context" => \Bitrix\Main\Authentication\Context object ) or just a plain array of fields.

This method uses the default strategy defined in the class.

Tags
throws
Exception
Return values
AddResult

Contains ID of inserted row

addMulti()

Adds several rows to entity table.

public static addMulti(mixed $rows[, bool $ignoreEvents = false ]) : AddResult

This method uses the default strategy defined in the class.

Parameters
$rows : mixed
$ignoreEvents : bool = false
Tags
throws
ArgumentException
throws
SystemException
Return values
AddResult

addPacket()

Create one and more coupons for discount.

public static addPacket(array<string|int, mixed> $data, int $count[, int $limit = 0 ]) : Result
Parameters
$data : array<string|int, mixed>

Coupon data.

$count : int

Coupos count.

$limit : int = 0

Maximum number of attempts.

Return values
Result

checkCoupon()

Check coupon - unique and exist.

public static checkCoupon(int $value, array<string|int, mixed>|int $primary, array<string|int, mixed> $row, Field $field) : bool|string
Parameters
$value : int

Coupon.

$primary : array<string|int, mixed>|int

Primary key.

$row : array<string|int, mixed>

Current data.

$field : Field

Field object.

Return values
bool|string

checkDiscountId()

Check discount id.

public static checkDiscountId(int $value, array<string|int, mixed>|int $primary, array<string|int, mixed> $row, Field $field) : bool|string
Parameters
$value : int

Discount id.

$primary : array<string|int, mixed>|int

Primary key.

$row : array<string|int, mixed>

Current data.

$field : Field

Field object.

Return values
bool|string

checkFields()

Checks the data fields before saving to DB. Result stores in the $result object

public static checkFields(Result $result, mixed $primary, array<string|int, mixed> $data) : mixed
Parameters
$result : Result
$primary : mixed
$data : array<string|int, mixed>
Tags
throws
ArgumentException
throws
SystemException

checkPacket()

Check data for create one or more coupons.

public static checkPacket(array<string|int, mixed> $data[, bool $newDiscount = false ]) : Result
Parameters
$data : array<string|int, mixed>

Coupon data.

$newDiscount : bool = false

New discount flag.

Return values
Result

checkType()

Check coupon type.

public static checkType(int $value, array<string|int, mixed>|int $primary, array<string|int, mixed> $row, Field $field) : bool|string
Parameters
$value : int

Coupon type.

$primary : array<string|int, mixed>|int

Primary key.

$row : array<string|int, mixed>

Current data.

$field : Field

Field object.

Return values
bool|string

cleanCache()

Cleans the tablet cache after data modifications.

public static cleanCache() : void

clearDiscountCheckList()

Clear discount list for update use coupons flag.

public static clearDiscountCheckList() : void

createCollection()

public static createCollection() : EO_DiscountCoupon_Collection
Return values
EO_DiscountCoupon_Collection

createObject()

public static createObject([mixed $setDefaultValues = = 'true' ]) : EO_DiscountCoupon
Parameters
$setDefaultValues : mixed = = 'true'
Return values
EO_DiscountCoupon

cryptoEnabled()

Returns true if crypto is enabled for a field.

public static cryptoEnabled(string $field[, string $table = null ]) : bool
Parameters
$field : string
$table : string = null
Return values
bool

delete()

Deletes row in entity table by primary key

public static delete(mixed $primary) : DeleteResult
Parameters
$primary : mixed
Tags
throws
Exception
Return values
DeleteResult

deleteByDiscount()

Delete all coupons for discount.

public static deleteByDiscount(int $discount) : void
Parameters
$discount : int

Discount id.

disableCheckCouponsUse()

Disable checking use coupons for discount before multiuse add/update/delete.

public static disableCheckCouponsUse() : void

enableCheckCouponsUse()

Enable checking use coupons for discount after multiuse add/update/delete.

public static enableCheckCouponsUse() : void

enableCrypto()

Sets a flag indicating crypto support for a field.

public static enableCrypto(string $field[, string $table = null ][, bool $mode = true ]) : mixed
Parameters
$field : string
$table : string = null
$mode : bool = true

generateCoupon()

Create coupon code.

public static generateCoupon([bool $check = false ]) : string
Parameters
$check : bool = false

Check new coupon or no.

Return values
string

getById()

Returns selection by entity's primary key

public static getById(mixed $id) : EO_DiscountCoupon_Result
Parameters
$id : mixed

Primary key of the entity

Return values
EO_DiscountCoupon_Result

getByPrimary()

Returns selection by entity's primary key and optional parameters for getList()

public static getByPrimary(mixed $primary[, array<string|int, mixed> $parameters = = '[]' ]) : EO_DiscountCoupon_Result
Parameters
$primary : mixed

Primary key of the entity

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

Additional parameters for getList()

Return values
EO_DiscountCoupon_Result

getCollectionClass()

Returns class of Object collection for current entity.

public static getCollectionClass() : string|Collection
Return values
string|Collection

getCollectionClassName()

Returns class name (without namespace) of Object collection for current entity.

public final static getCollectionClassName() : string
Return values
string

getConnectionName()

Returns connection name for entity

public static getConnectionName() : string
Return values
string

getCount()

Performs COUNT query on entity and returns the result.

public static getCount([array<string|int, mixed>|ConditionTree $filter = array() ][, array<string|int, mixed> $cache = array() ]) : int
Parameters
$filter : array<string|int, mixed>|ConditionTree = array()
$cache : array<string|int, mixed> = array()

An array of cache options "ttl" => integer indicating cache TTL

Tags
throws
ObjectPropertyException
throws
SystemException
Return values
int

getCouponTypes()

Returns coupon types list.

public static getCouponTypes([bool $extendedMode = false ]) : array<string|int, mixed>
Parameters
$extendedMode : bool = false

Get type ids or ids with title.

Return values
array<string|int, mixed>

getEntity()

Returns entity object

public static getEntity() : EO_DiscountCoupon_Entity
Return values
EO_DiscountCoupon_Entity

getList()

Executes the query and returns selection by parameters of the query. This function is an alias to the Query object functions

public static getList([array<string|int, mixed> $parameters = = '[]' ]) : EO_DiscountCoupon_Result
Parameters
$parameters : array<string|int, mixed> = = '[]'

An array of query parameters, available keys are:
"select" => array of fields in the SELECT part of the query, aliases are possible in the form of "alias"=>"field";
"filter" => array of filters in the WHERE/HAVING part of the query in the form of "(condition)field"=>"value"; also could be an instance of Filter;
"group" => array of fields in the GROUP BY part of the query;
"order" => array of fields in the ORDER BY part of the query in the form of "field"=>"asc|desc";
"limit" => integer indicating maximum number of rows in the selection (like LIMIT n in MySql);
"offset" => integer indicating first row number in the selection (like LIMIT n, 100 in MySql);
"runtime" => array of entity fields created dynamically;
"cache => array of cache options:
"ttl" => integer indicating cache TTL;
"cache_joins" => boolean enabling to cache joins, false by default.

Return values
EO_DiscountCoupon_Result

getMap()

Returns entity map definition.

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

getObjectClassName()

Returns class name (without namespace) of Object for current entity.

public final static getObjectClassName() : string
Return values
string

getRow()

Returns one row (or null) by parameters for getList()

public static getRow(array<string|int, mixed> $parameters) : array<string|int, mixed>|null
Parameters
$parameters : array<string|int, mixed>

Primary key of the entity

Tags
throws
ArgumentException
throws
ObjectPropertyException
throws
SystemException
Return values
array<string|int, mixed>|null

getRowById()

Returns one row (or null) by entity's primary key

public static getRowById(mixed $id[, array<string|int, mixed> $parameters = [] ]) : array<string|int, mixed>|null
Parameters
$id : mixed

Primary key of the entity

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

Additional parameters for getList()

Tags
throws
ArgumentException
throws
ObjectPropertyException
throws
SystemException
Return values
array<string|int, mixed>|null

getTableName()

Returns DB table name for entity.

public static getTableName() : string
Return values
string

getTitle()

public static getTitle() : string|null
Return values
string|null

isCacheable()

You can disable cache for the tablet completely.

public static isCacheable() : bool
Return values
bool

isCheckedCouponsUse()

Returns current checking use coupons mode.

public static isCheckedCouponsUse() : bool
Return values
bool

isValidCouponType()

Check valid coupon type.

public static isValidCouponType(int $couponType) : bool
Parameters
$couponType : int

Coupon type.

Return values
bool

onAfterAdd()

Default onAfterAdd handler. Absolutely necessary.

public static onAfterAdd(Event $event) : void
Parameters
$event : Event

Current data for add.

onAfterDelete()

Default onAfterDelete handler. Absolutely necessary.

public static onAfterDelete(Event $event) : void
Parameters
$event : Event

Current data for delete.

onAfterUpdate()

Default onAfterUpdate handler. Absolutely necessary.

public static onAfterUpdate(Event $event) : void
Parameters
$event : Event

Current data for update.

onBeforeAdd()

Default onBeforeAdd handler. Absolutely necessary.

public static onBeforeAdd(Event $event) : EventResult
Parameters
$event : Event

Current data for add.

Return values
EventResult

onBeforeUpdate()

Default onBeforeUpdate handler. Absolutely necessary.

public static onBeforeUpdate(Event $event) : EventResult
Parameters
$event : Event

Current data for update.

Return values
EventResult

onDelete()

Default onDelete handler. Absolutely necessary.

public static onDelete(Event $event) : void
Parameters
$event : Event

Current data for delete.

onUpdate()

Default onUpdate handler. Absolutely necessary.

public static onUpdate(Event $event) : void
Parameters
$event : Event

Current data for update.

postInitialize()

public static postInitialize(Entity $entity) : null
Parameters
$entity : Entity
Return values
null

prepareCouponData()

Prepare coupon data. Only for admin list pages.

public static prepareCouponData(array<string|int, mixed> &$fields) : Result
Parameters
$fields : array<string|int, mixed>

Coupon data.

Return values
Result

query()

Creates and returns the Query object for the entity

public static query() : EO_DiscountCoupon_Query
Return values
EO_DiscountCoupon_Query

saveApplied()

Save coupons applyed info.

public static saveApplied(array<string|int, mixed> $coupons, int $userId, DateTime $currentTime) : array<string|int, mixed>|bool
Parameters
$coupons : array<string|int, mixed>

Coupons list.

$userId : int

User id.

$currentTime : DateTime

Current datetime.

Return values
array<string|int, mixed>|bool

setDiscountCheckList()

Fill discount list for update use coupons flag.

public static setDiscountCheckList(array<string|int, mixed>|int $discountList) : void
Parameters
$discountList : array<string|int, mixed>|int

Discount ids for check.

unsetEntity()

public static unsetEntity(mixed $class) : mixed
Parameters
$class : mixed

update()

Updates row in entity table by primary key

public static update(mixed $primary, array<string|int, mixed> $data) : UpdateResult
Parameters
$primary : mixed
$data : array<string|int, mixed>

An array with fields like array( "fields" => array( "FIELD1" => "value1", "FIELD2" => "value2", ), "auth_context" => \Bitrix\Main\Authentication\Context object ) or just a plain array of fields.

Tags
throws
Exception
Return values
UpdateResult

updateMulti()

public static updateMulti(array<string|int, mixed> $primaries, array<string|int, mixed> $data[, bool $ignoreEvents = false ]) : UpdateResult
Parameters
$primaries : array<string|int, mixed>
$data : array<string|int, mixed>
$ignoreEvents : bool = false
Tags
throws
ArgumentException
throws
SystemException
Return values
UpdateResult

updateUseCoupons()

Update use coupon flag for discount list.

public static updateUseCoupons() : void

validateCoupon()

Returns validators for COUPON field.

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

validateDiscountId()

Returns validators for DISCOUNT_ID field.

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

validateType()

Returns validators for TYPE field.

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

wakeUpCollection()

public static wakeUpCollection(mixed $rows) : EO_DiscountCoupon_Collection
Parameters
$rows : mixed
Return values
EO_DiscountCoupon_Collection

wakeUpObject()

public static wakeUpObject(mixed $row) : EO_DiscountCoupon
Parameters
$row : mixed
Return values
EO_DiscountCoupon

        
On this page

Search results