This is something I've done in the past outside of Drupal but I can't seem to figure out how to do this with Drupal Commerce.

I need the ability to do the following:

  1. Allow the user to create parts via category (this could be a taxonomy term with fields like name, image, sku component, description, price markup...)

  2. Allow the user to create a new product and select which parts can be placed on this product.

  3. When the end user is looking at the product page, they will select which parts they want for this product.

  4. When they select their parts the PHP script, on submission, will create a line item with sku comprised of the parts selected and a price made up of the base price of the product + any additional cost per part.

So, for instance, part category A has 5 parts. Standard and 4 upgrades. If the user selects an upgrade from Category A, it will modify the SKU on submission AND update the price based on the markup price of the part's price field.

Anybody following me here? How do I do this? I'll code it myself if I have to, I just need to know where to begin.


Try this rule, it will alter the line item's label based on tokens specified when a product type "Product" is added to cart. This is how you can keep it specific to a certain product type. A line item's label is defaulted to the product's SKU.

All of your term-reference attributes will be exposed as tokens. For formatting ideas, check out Commerce AutoSKU which generates product SKUs at product creation (not line item.)

{ "rules_alter_line_item_sku" : {
"LABEL" : "Alter line item label",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_cart" ],
"ON" : { "commerce_cart_product_add" : [] },
"IF" : [
  { "entity_is_of_type" : { "entity" : [ "commerce-line-item" ], "type" : "commerce_line_item" } },
  { "data_is" : { "data" : [ "commerce-product:type" ], "value" : "product" } }
"DO" : [
  { "data_set" : {
      "data" : [ "commerce-line-item:line-item-label" ],
      "value" : "[commerce-product:type]-[commerce-order:uid]"
| improve this answer | |

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.