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.

  1. 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.

  2. 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.

  • 1) 100 categories x 200 places = 2000 products. BRRRR 2) How can I create a pricing rule ? Ok with the Rules module, but how can I insert the "calculated" price in the cart ? – ZioBudda Nov 6 '12 at 11:49
  • You can multiply the line item price based on a variable in rule. If you have some coding ability you code possibly write a case statement but if not you can do the Rules if conditional but again, that's going to be 2000 conditions. You're best bet is to do it programtically. – o_O Nov 12 '12 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.