- Attributes variations with prices... -


First of all, I've posted some comments as for the display choice (http://www.drupalcommerce.org/node/293#comment-2490)
and the attributes in the FAQ (http://www.drupalcommerce.org/faq/product-attributes#comment-2491)

I'm french (excuse my englih) photographer and I've tried to put some extra attributes to an image, concerning
• its print "support" (paper mat, paper glossy..., plastic... numeric)
• and dimensions of the print.

Of course, the price depend on these attributes that the custumer can choose before adding to the cart, but the image itself is always the same.

With Drupal commerce, I don't want to create as much products as supports I have, because it's too long and conter productive, and heavier for the database (isn't it ?)

After several days of reading, watching and fighting with drupal commerce, I've found this answer below. Tell me please if I go straight in the wall or not :/
• I've downloaded commerce_custom_line_items because wanted to put different choices (I also make some drawings, whose dimensions cannot be changed)
• created a new line item called photo for ex.
• created one field in this new line item, called "choose your support" (field_support), list field (texte), and ad my different support type
• created a rule for each type of support similar to this:

{ "rules_print_fine_art_15_x_20" : {
    "LABEL" : "Print Fine-art 15 x 20",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "commerce_line_item", "commerce_product_reference" ],
    "ON" : [ "commerce_product_calculate_sell_price" ],
    "IF" : [
      { "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "field_support" } },
      { "text_matches" : {
          "text" : [ "commerce-line-item:field-support" ],
          "match" : "Print Fine-art 15 x 20"
    "DO" : [
      { "commerce_line_item_unit_price_add" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : "3500",
          "component_name" : "base_price"

I've noticed that the price is in cents (here 3500 means 35.00€)
In my case, the basic price is not the same for all pictures, so I used commerce_line_item_unit_price_add, and not only "change the price of"

Is it a good or bad idea ??

Thank you

Posted: Nov 16, 2011