this line will break if $product doesn't exist in line 143
could this logic be changed to a chained elseif() ?

what do you think?
lmk and I'll adapt the code