Created a file handler. The number in the basket is updated, but the price is not. Why - it is not clear.

<? require_once($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php"); if(CModule::IncludeModule('sale')){ $arBasketItems = array(); $dbBasketItems = CSaleBasket::GetList( array( "NAME" => "ASC", "ID" => "ASC" ), array( "FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL", "PRODUCT_ID" => $_POST['id'] ), false, false, array("ID", "PRODUCT_ID", "QUANTITY", "PRICE", "NAME") ); while ($arItems = $dbBasketItems->Fetch()) { $arBasketItems[] = $arItems; } } $price = (int)$arBasketItems[0]['PRICE']; $count = (int)$arBasketItems[0]['QUANTITY']; if (CModule::IncludeModule("catalog")) { if($_POST['type']=='min'){ $arFields = array( "QUANTITY" => $count-1, "PRICE" => $price-1 ); } if($_POST['type']=='plus'){ $arFields = array( "QUANTITY" => $count + 1, "PRICE" => $price+1 ); } $ID = CSaleBasket::Update($arBasketItems[0]['ID'], $arFields); } ?> 
  • why do you assign a variable to CSaleBasket::Update this method returns nothing. Are you sure that in price you have a number? - Nikolaj Sarry

1 answer 1

Here is the answer:

 $arFields = array( "CALLBACK_FUNC" => "", "PRODUCT_PROVIDER_CLASS" => "", "CUSTOM_PRICE" => "Y", "IGNORE_CALLBACK_FUNC" => "Y" ); 

There are two parameters that are not documented anywhere: "CUSTOM_PRICE", "IGNORE_CALLBACK_FUNC". They allow you to disable GetOptimalPrice and use a custom price.

  • Oh, and what is this written in the documentation : CUSTOM_PRICE Indicates whether, for example, discounts can change the value of the position or not. Usually this flag is set in the administrative department when the price is corrected in the manual editing form. Y / N value (N is the default). IGNORE_CALLBACK_FUNC - Y \ N. By default, N. If you set the Y parameter, CALLBACK_FUNC and PRODUCT_PROVIDER_CLASS will not be called. - Nikolaj Sarry pm
  • Oh, really written! - Oleg Nechaev