Today, I spent several hours messing about with the Rules UI and googling Commerce docs and forums, trying to figure out how to provide a field where the customer can freely choose the price of a donation-style product. In the end, I found pointers to a method which turns out to work pretty well.
My use case
Donation as a Drupal 7 Commerce product. Donation amount can be chosen freely, above a fixed minimum. The customer/donor receives a reward (but that is not actually relevant here).
This is how I did it:
- Install Commerce Customizable Products
- Add price field
- Add a line item type at admin/commerce/config/line-items. It is created with a bunch of default fields, which you cannot change.
- Add a field of the Price type (TODO: Figure out how to set a minimum)
- Make it visible
- At the field display settings of your product display content type (something like admin/structure/types/manage/product-display/display), edit the settings for the product reference field. Change Add to Cart line item type to your new line item type. Click Update and Save.
- Make it count
- Add a new rule at admin/config/workflow/rules. Choose the event Calculating the sell price of a product.
- Add an Entity has field condition with
commerce-line-itemfor Entity and your price field for Field.
- Add a Set the unit price to a specific amount action with
commerce-line-itemfor Line item and something like