I have a a custom field value for each product. This custom field is inserted with the code below :
Store the variable in the $_SESSION, then loop thru them and pick the highest, so you can use it later anywhere in your code
$_SESSION