Example #1
0
             }
         }
         $fields = array("DELIVERY_ID" => $deliveryId, "SORT" => $sort, "PARAMS" => $params);
         $res = $restriction->save($fields, $restrictionId);
         if (!$res->isSuccess()) {
             $arResult["ERROR"] .= implode(".", $res->getErrorMessages());
         }
         $arResult["HTML"] = getRestrictionHtml($deliveryId);
         break;
     case "delete_restriction":
         $restrictionId = isset($_REQUEST['restrictionId']) ? intval($_REQUEST['restrictionId']) : 0;
         $deliveryId = isset($_REQUEST['deliveryId']) ? intval($_REQUEST['deliveryId']) : 0;
         if (!$restrictionId) {
             throw new \Bitrix\Main\ArgumentNullException('restrictionId');
         }
         $dbRes = \Bitrix\Sale\Delivery\Restrictions\Table::getById($restrictionId);
         if ($fields = $dbRes->fetch()) {
             $restriction = Services\Manager::getRestrictionObject($fields["CLASS_NAME"]);
             $res = $restriction->delete($restrictionId, $deliveryId);
             if (!$res->isSuccess()) {
                 $arResult["ERROR"] .= implode(".", $res->getErrorMessages());
             }
         } else {
             $arResult["ERROR"] .= "Can't find restriction with id: " . $restrictionId;
         }
         $arResult["HTML"] = getRestrictionHtml($deliveryId);
         break;
     default:
         $arResult["ERROR"] = "Error! Wrong action!";
         break;
 }