<input type="checkbox" id="test" name="horns">
<label for="test">Horns</label>
<?
if ( (in_array($arResult["ID"], $delaydBasketItems)) || (isset($itInDelay)) ) { ?>
<script>
$('#test').attr('checked', true);
</script>
<?}?>
<?php
<?php
$arResult["ID"] = 5;
$delaydBasketItems = [2,4,3,6,5];
?>
<input type="checkbox" name="test" id="test">
<?php
if ( in_array($arResult["ID"], $delaydBasketItems) || isset($itInDelay) ) {
?>
<script>
$('#test').attr('checked', true);
</script>
<?php } ?>