GetList
CDBResult CSaleDiscount::GetList( string &by, string &order, array arFilter = Array() );
The method GetList returns a sorted and filtered list of discounts.
Parameters
Parameter | Description |
---|---|
by | Specifies the name of the parameter by which the result is to be sorted.
Can be one of the following values:
|
order | Sort order. Can be one of the following:
|
arFilter | The filter is an associated array whose keys are the discount parameter
names, and values are the conditions. The following keys are possible:
|
Return Values
Returns an instance of CDBResult, containing a set of associated arrays with the following keys.
Key | Description |
---|---|
ID | The discount ID. |
LID | The ID of the site to which this discount is bound. |
PRICE_FROM | Minimum total order price to which this discount is applicable. |
PRICE_TO | Maximum total order price to which this discount is applicable. |
CURRENCY | Currency in which all money values are specified in this record. |
DISCOUNT_VALUE | Discount value. |
DISCOUNT_TYPE | Type of the discount value (P - percentage, V - absolute value). |
ACTIVE | Flag indicating the discount is active (Y/N). |
SORT | Sort weight. If more than one discount can be applied to an order price, the discount with the less SORT is taken first. |
Example
<? // Get the value of the active discount for the current site // and the order price $ORDER_PRICE in the base currency of the site $db_res = CSaleDiscount::GetList(($by="SORT"), ($order="ASC"), Array("LID"=>SITE_ID, "ACTIVE"=>"Y", "PRICE"=>$ORDER_PRICE)); if ($ar_res = $db_res->Fetch()) { echo "Discount is "; if ($ar_res["DISCOUNT_TYPE"] == "P") { echo $ar_res["DISCOUNT_VALUE"]."%"; } else { echo CurrencyFormat($ar_res["DISCOUNT_VALUE"], $ar_res["CURRENCY"]); } } ?>
© «Bitrix24», 2001-2024