Delete
Method has been deprecated. Use the class methods \Bitrix\Sale\Basket of the new core.
bool CSaleBasket::Delete( int ID );
Method deletes a shopping cart record with ID. Non-static method.
Examples
Example 1:
<? if (CSaleBasket::Delete(22)) echo "Record has been deleted successfully"; ?>
Example 2:
This method can be used for deleting shopping cart records that have been already converted to orders. It means, that we can delete the record from the order composition. You need to remember that after using the method, you need to update total order amount. For example:
$contents = array(); $dbBasketItems = CSaleBasket::GetList( array( "NAME" => "ASC", "ID" => "ASC" ), array( "LID" => SITE_ID, "ORDER_ID" => $order_id, ) ); while ($arItems = $dbBasketItems->Fetch()){ $contents[] = $arItems; } $sum = 0; foreach($contents as $basket_item){ if($basket_item['DISCOUNT_PRICE']>0){ $sum += $basket_item['DISCOUNT_PRICE']*$basket_item['QUANTITY']; }else{ $sum += $basket_item['PRICE']*$basket_item['QUANTITY']; } } $arFields = array( "PRICE" => $sum, ); CSaleOrder::Update($order_id, $arFields);
© «Bitrix24», 2001-2024