I am using jQuery to calculate prices. Here is a small snippet of my JavaScript:
// Prices: radio var curLam = \"gloss\"; $(\"input[name=lamination]\").click
You could put the ID of the product into an input element and then when you submit into the shopping cart, then the value should be in your php $_POST variables.
There you can check the price and other information straight from your database.