Commerce: 1 product but N prices I have a problem/question.

My client need to sell one product but the price of this product (digital, so no shipping cost or other) is based on a field in a table. Explain: X categories and Y places. Each combination of X per Y return a different price for the only 1 product.

How can I set the price of this product at "checkout" ?
In node Z (where categories is 1 and places is 2, for example) I can write the correct cost value (via preprocess_node, or template function or other), but in the cart?
You have two options.


You can create one product for each combonation of X and Y and have those as values on the product. If you reference all the products on the node, commerce can turn the value of X and Y into a dropdown which will trigger an ajax update, changing the other data for the product like this price.
The other options if you don't want to create a product for each combonation (my preferred solution), would be to create a pricing rule, custom code is probably needed here, to calculate and set the unit price on the line item based on X/Y data.