GetList
CDBResult CSaleBasket::GetList( string &by, string &order, array arFilter = array() );
The method GetList returns a set of the basket records. The set returned is filtered by arFilter, sorted by by in the direction order.
Parameters
Parameter | Description |
---|---|
by | Name of the field by which the list is to be sorted. The following
values are possible:
|
order | Sort order. The following values are possible:
|
arFilter | An array of the format Array("basket element parameter
name"=>"filter condition" [, ...]). Filtering field
can have the following values:
|
Returned values
Returns an instance of the CDBResult class containing a set of associated arrays with the following keys.
Key | Description |
---|---|
ID | The record ID. |
PRODUCT_ID | The product ID unique within the module. |
PRODUCT_PRICE_ID | The product ID (auxiliary). |
PRICE | Price of the product, per unit. |
CURRENCY | Currency of the product price. |
WEIGHT | Weight of the product unit. |
QUANTITY | Number of products. |
LID | The site from which the purchase originates. |
DELAY | Indicates the product item is saved for later purchase (Y/N). |
CAN_BUY | Indicates the product can be purchased (Y/N). |
NAME | The product name. |
CALLBACK_FUNC | Name of the callback function used to maintain the basket actuals. |
MODULE | Module adding the product to the basket. |
NOTES | Other special notes. |
ORDER_CALLBACK_FUNC | Name of the ordering process callback function. |
DETAIL_PAGE_URL | URL of the page with the product details. |
FUSER_ID | The internal ID of the basket owner (not the same as the user ID). |
ORDER_ID | The ID of the sale order containing this record (product). If a product is in the basket but is not ordered yet, this field is NULL. |
DATE_INSERT | The date the product was added. |
DATE_UPDATE | The date the record was modified. |
DISCOUNT_PRICE | Discount for the product. Valid only upon ordering. |
Example
<? // Display the actual basket of the current user // (implemented by the API function GetBasketList()) // initialise the basket owner internal ID CSaleBasket::Init(false); // Result array $arRes = array(); // Select all active but not ordered records // of the current owner for the current site $db_res = CSaleBasket::GetList(($by="NAME"), ($order="ASC"), array("FUSER_ID"=>$_SESSION["SALE_USER_ID"], "LID"=>SITE_ID, "ORDER_ID"=>"NULL")); while ($ar_res = $db_res->GetNext()) { // If the callback function is specified... if (strlen($ar_res["CALLBACK_FUNC"])>0) { // Update the basket parameters by calling the callback function CSaleBasket::UpdatePrice($ar_res["ID"], $ar_res["CALLBACK_FUNC"], $ar_res["MODULE"], $ar_res["PRODUCT_ID"], $ar_res["QUANTITY"]); // Query an array of newly actual parameters $ar_res = CSaleBasket::GetByID($ar_res["ID"]); } $arRes[] = $ar_res; } // Display the actual basket information echo "<pre>"; print_r($arRes); echo "</pre>"; ?>
© «Bitrix24», 2001-2024