CSaleBasket::OrderBasket(
int OrderID,
int FUSER_ID = 0,
string strLang = SITE_ID,
array arDiscounts = False
);
The method OrderBasket attaches product items from the basket to the
specified order. The method attaches those product items that are currently
available and not saved for later purchase. This method is called at the time of
ordering the basket products.
Parameters
Parameter
Description
OrderID
The ID of an order to which the products should be attached.
FUSER_ID
The internal ID of the basket owner. If omitted (null) or if the current
user is not granted write permission for the e-Store module, the
current user internal ID is used instead.
strLang
The site from which the basket is set to be ordered. If omitted, the
current site is used.
arDiscounts
Associated array containing the discount values. Each key in the array
is the ID of a basket item record. The corresponding value is the value of
discount. If omitted (set to false), discounts are not applied.
Example
<?
// Attach records of the current user basket to the order $ORDER_ID
// Set the discount to 5%
$arDiscounts = array();
$arRes = GetBasketList();
for ($i = 0; $i<count($arRes); $i++)
{
if ($arRes[$i]["DELAY"]=="N" && $arRes[$i]["CAN_BUY"]=="Y")
{
$curDiscount = roundEx(DoubleVal($arRes[$i]["PRICE"])*5/100, 2);
$arDiscounts[IntVal($arRes[$i]["ID"])] = $curDiscount;
}
}
// Create order considering the discount value
* * *
// $ORDER_ID contains the order ID
CSaleBasket::OrderBasket($ORDER_ID,
$_SESSION["SALE_USER_ID"], SITE_ID, $arDiscounts);
?>