\Commerce\Discounts
Templating
Global Functions
Website
\Components\Website\Designs \Components\Website\Media \Components\Website\Pages \Components\Website\Pages\Forms \Components\Website\Posts \Components\Website\Posts\Categories
Customers
\Components\Customers\Contacts \Components\Customers\Contacts\Relationships \Components\Customers\Contacts\Relationships\Types \Components\Customers\Groups
Marketing
\Components\Marketing\EmailMarketing \Components\Marketing\Events \Components\Marketing\Events\Attendees \Components\Marketing\Events\Categories \Components\Marketing\Events\Locations \Components\Marketing\Events\Recurring \Components\Marketing\Events\Recurring\Rules \Components\Marketing\SMSMarketing
Commerce
\Components\Commerce\Carts \Components\Commerce\Carts\Current \Components\Commerce\Discounts
METHODS
\Components\Commerce\Products \Components\Commerce\Products\Brands \Components\Commerce\Products\Categories \Components\Commerce\Products\Inventory \Components\Commerce\RecurringSales\Items \Components\Commerce\Sales \Components\Commerce\Sales\Items \Components\Commerce\Sales\Receipts \Components\Commerce\Sales\Receipts\Allocations
Settings
\Components\Settings\Administrators \Components\Settings\CustomFields \Components\Settings\Domains
Other Apps
\Components\Website\Comments \Components\Commerce\Affiliates \Components\Commerce\Affiliates\Administrators \Components\Commerce\Affiliates\Commissions \Components\Commerce\Affiliates\Payments \Components\Commerce\RecurringSales \Components\Commerce\RecurringSales\StoredCards
Framework
\Framework\Caching \Framework\Data\Util \Framework\DOM\CurrentContext \Framework\HTML\Converters \Framework\HTTP\Cookies \Framework\HTTP\Redirection \Framework\HTTP\Request \Framework\HTTP\Session \Framework\HTTP\TabState \Framework\HTTP\UserAgent \Framework\I18N\CompanyTypes \Framework\I18N\Countries \Framework\I18N\Languages

Discounts

Allow you to create discounts on products, categories and brands.

Methods

Invoke via \Components\Commerce\Discounts::method()
Click a method name to copy it.
- ` void activateCodeDiscountWithCode($strDiscountCode) `
Activates a discount with a specific code
Parameters:
- $strDiscountCode
mixed
- ` void activatedCodeDiscountRemoveAll() `
Removes all discounts that have been activated by code
- ` bool activatedCodeDiscountsIsCodeApplied($strDiscountCode) `
Returns whether a discount with a specific id has been applied
Parameters:
- $strDiscountCode
mixed
Return
bool
- ` \Iterator dbGetAllIterable($arrQuery) `
Returns the raw rows dbGetAll() would return as an iterator, without building them all into an array

The dbGetAll() counterpart of getAllIterable(), for scans over every stored row of a large table (eg: the site-wide content scans in \Framework\Developer\Refactoring). Rows are as stored - JSON fields are not decoded - and are not entity-cached. Because it bypasses getAll(), components that override getAll() are iterated; search queries and components overriding dbGetAll() are refused.
Parameters:
- $arrQuery
mixed
Return
Yields Discounts
- ` array fieldsGetAll($bCached) `
Returns all the columns this component supports
Parameters:
- $bCached
mixed
Return
array
- ` array get($iDiscountId) `
Gets a record from the database
Parameters:
- $iDiscountId
int
A record's discount_id
Return
- ` array getAll($arrQuery) `
Return a set of records from the database
Parameters:
- $arrQuery
mixed
Return
Array of Discounts
- ` \Iterator getAllIterable($arrQuery) `
Returns the entities getAll() would return as an iterator, without building them all into an array

For result sets too large to hold as arrays (eg: every recipient of a marketing send) - only the database driver's compact buffer of the result is held, a fraction of getAll()'s memory. Runs the same SQL as getAll(), and runs it now, as getAll() would; rows are decoded as you iterate.
Search queries are not supported, rows are not entity-cached, and components that override getAll() or dbGetAll() (eg: merging in defaults) are refused rather than iterated without their extra rows.
Parameters:
- $arrQuery
mixed
Return
Yields Discounts
- ` bool delete($iDiscountId, $bDeleteMedia) `
Deletes a record from the database
Parameters:
- $iDiscountId
int
A record's discount_id
- $bDeleteMedia
mixed
Return
Returns true if record existed and was deleted, otherwise false
- ` int getCodeDiscountsForPublicCount() `
Retrieves the number of discounts which require a code and enabled for public
Return
int
- ` mixed getColumn($iDiscountId, $strColumn) `
Gets a single field from a record
Parameters:
- $iDiscountId
int
A record's discount_id
- $strColumn
mixed
Return
mixed
- ` int getContactId() `
Retrieves the contact id on which discounts are currently meant to be applied to.
This is useful for custom algorithm discounts
Return
int
- ` int getCount($arrFilter) `
Returns the number of records in the database (matching the filter if specified)
Parameters:
- $arrFilter
mixed
Return
int
- ` string|int save($arrEntity) `
Saves a record into the database
Parameters:
- $arrEntity
mixed
Return
string|int
- ` void saveColumn($iDiscountId, $strColumn, $strValue) `
Saves a specific column of a row into a database
Parameters:
- $iDiscountId
int
A record's discount_id
- $strColumn
mixed
- $strValue
mixed
- ` array search($strSearch, $arrQuery) `
Performs a search
Parameters:
- $strSearch
mixed
- $arrQuery
mixed
Return
Array of Discounts that match the search query.

Database Fields

The following fields are used when retrieving and saving entities:
- `discount_id`
int (11)
- `discount_title`
string (255)
- `discount_type`
Default value: flat
- `discount_value`
string (16777215)
- `discount_scope`
Default value: cart
- `discount_usage_limit`
int (11)
- `discount_usage_per_customer`
int (11)
- `discount_products_total_threshold`
decimal (10,4)
- `discount_code`
string (31)
- `discount_start_date`
datetime
- `discount_end_date`
datetime
- `discount_entity_type`
string (255)
- `discount_entities`
string (16777215)
- `discount_excluded_product_entities`
string (16777215)
- `discount_is_applicable_for_someone_else`
0 or 1
- `discount_is_rounding_enabled`
0 or 1
- `discount_is_enabled_public`
0 or 1
Default value: 1
- `discount_is_enabled_admin`
0 or 1
Default value: 1
- `discount_auto_delete`
0 or 1
- `affiliate_id`
int unsigned (10)
- `condition_id`
int (10)