Hi,
Ohh, so the product is sold out ? Now I begin to understand the problematic and why you have no characteristic selection on that page.
Indeed, in that case, it should not trigger an error.
You'll ahve to change the line:
$js = "var el = document.querySelector('[name=\"".$id."\"]'); el.checked = true; hikashopUpdateVariant(el);";
to:
$js = "var el = document.querySelector('[name=\"".$id."\"]'); if(el) el.checked = true; hikashopUpdateVariant(el);";
And that will remove the error for products without any stock.