You must first check if the product meets your initial conditions. Then you have to check whether the variables you are comparing are declared or have data. For example, if your $itemPrice has no data it will suppress the exception and your program will stop the moment you call it to compare.

Only top voted, non community-wiki answers of a minimum length are eligible