Your entire if statements need to be outside the script tag. So if you want the if statement it should roughly look like:
if product
script open
product structured data
script closed
end if
I can’t tell if you’re on a product file or not. If you are, you shouldn’t need the if statement at all.