Bitrix Site Manager

Adding items to basket

The Commercial Catalog module includes wrapper functions that are used in connection with the e-Store module.

Add2Basket


int
Add2Basket(
 int PRICE_ID [,
 int QUANTITY ] 
);

The Add2Basket function adds a product item to the shopping cart given the price code PRICE_ID and the required QUANTITY (one by default) and returns the product position ID in the shopping cart.

Parameters

Parameter Description
PRICE_IDProduct item price code.
QUANTITY Number of items to be added (one by default).

Example


<?
if (CModule::IncludeModule("sale") && 
    CModule::IncludeModule("catalog"))
{
    if (($action == "ADD2BASKET" || $action == "BUY") && 
        IntVal($PRICE_ID)>0)
    {
        Add2Basket($PRICE_ID);
        if ($action == "BUY")
            LocalRedirect("basket.php");
    }
}
?>

Callback Functions


array
CatalogBasketCallback(
 int PRODUCT_ID [,
 int QUANTITY] )

);
void
CatalogBasketOrderCallback(
 int PRODUCT_ID,
 int QUANTITY
);

The callback functions are used for processing the shopping cart and order operations. See the e-Store module reference for more information on the callback functions.