16 public function run(
int $id)
18 $deleteBasketItemResult = $this->deleteBasketItem($id);
19 if (!$deleteBasketItemResult->isSuccess())
21 $this->
addErrors($deleteBasketItemResult->getErrors());
25 public function deleteBasketItem(
int $id):
Sale\
Result
32 $basketClass = $registry->getBasketClassName();
34 $basketIterator = $basketClass::getList([
35 'select' => [
'ORDER_ID',
'FUSER_ID',
'LID'],
40 if ($basketItemData = $basketIterator->fetch())
42 if (empty($basketItemData[
'ORDER_ID']))
44 $basket = $basketClass::loadItemsForFUser($basketItemData[
'FUSER_ID'], $basketItemData[
'LID']);
45 if ($basket && !$basket->isEmpty())
47 $basket->getItemByBasketCode($id)->delete();
49 $saveResult = $basket->save();
50 if ($saveResult->isSuccess())
52 $result->setData([
'basket' => $basket]);
57 foreach ($saveResult->getErrors() as $error)
83 'there is order with this basket item',
93 'basket item with id '.$id.
' is not exists',