In a Commerce project, the customer should be able to choose between 2 options with a radio field, for some products only, with a different price for each option. When a customer selects a radio option, the unit price should be changed accordingly and with ajax, and the line item updated I guess.

We also need that the admin enter PRICE A, PRICE B in 2 commerce_price fields when he creates new products, not by rule calculation neither +90 or -100 as in Commerce Pricing Attributes (because prices vary a lot and having to calculate each price difference would be a source of errors).

At the moment the lone idea I got to configure this is :

  • set a line item field with these radio options, shown in the add to cart form.
  • Then or a pricing rule which detects if the 2nd price exists, and is selected ; sets the 2nd price as the unit price ?

Or programmatically, with some hook ? Any suggestion would be really helpful.

2 Answers 2


Pricing rules was the right track. In order to configure 2 main prices for a single product :

Add a 2nd price field to the product type:

added a 2nd price field to my product type

Add a boolean field to the corresponding line item type:

boolean field to the corresponding line item

In the Add to Cart form settings of this field (admin/commerce/config/line-items/CUSTOM-line-item/fields/field_avec_aerien), check Include this field on Add to Cart forms for line items of this type.

Finally, in admin/commerce/config/product-pricing/rules/manage/, create (or clone & edit) a new pricing rule which set the unit price to 2nd price amount, when the boolean is checked by the customer in the add to cart form.

pricing rule which set the unit price to 2nd price amount

Pricing rules are very powerful, indeed !


Well, you should go for product attribute.

You've got a few tutorial about it on the drupalcommerce website :

Lucky you, one the commerce guys (Randy Fay) also make a video where he briefly talk about it : http://vimeo.com/user5912539 (can't remember which one :x)

  • Thanks. Anyway this does not answer my question. In order to change the price with an attribute, it's possible to use pricing attributes module, but as explained above, it doesn't fit this specific case.
    – Kojo
    Commented Sep 3, 2014 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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