Hello everyone, help solve the issue. There is a handler for adding products to the basket:

if(isset($_REQUEST["product_id"]) && CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")){ foreach($_REQUEST['product_id'] as $PRODUCT_ID){ $quantity = 0; if((int)$_REQUEST['quantity_'.(int)$PRODUCT_ID] > 0) $quantity = (int)$_REQUEST['quantity_'.(int)$PRODUCT_ID]; Add2BasketByProductID( (int)$PRODUCT_ID, $quantity); } LocalRedirect($APPLICATION->GetCurPage()); } 

if I transfer the quantity 0, then the goods in the quantity 1 drop into the basket. Everything is logical, in the bitrix documentation it is written that the standard quantity of the goods falls in the amount of 1 piece. What should be added to the handler, so that with the transferred quantity 0 the product does not fall into the basket?

    2 answers 2

    It is necessary to modify the code as follows (add Add2BasketByProductID inside if):

     if(isset($_REQUEST["product_id"]) && CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")){ foreach($_REQUEST['product_id'] as $PRODUCT_ID){ $quantity = 0; if((int)$_REQUEST['quantity_'.(int)$PRODUCT_ID] > 0) { $quantity = (int)$_REQUEST['quantity_'.(int)$PRODUCT_ID]; Add2BasketByProductID( (int)$PRODUCT_ID, $quantity); } } LocalRedirect($APPLICATION->GetCurPage()); } 

      Solved the question a little wrong:

       <?if(isset($_REQUEST["product_id"]) && CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) { foreach($_REQUEST['product_id'] as $PRODUCT_ID) { $quantity = 0; if((int)$_REQUEST['quantity_'.(int)$PRODUCT_ID] > 0) $quantity = (int)$_REQUEST['quantity_'.(int)$PRODUCT_ID]; if($quantity>0) Add2BasketByProductID((int)$PRODUCT_ID, $quantity); else { } } } ?> 

      Thank!