Let me start by saying I am aware of this module: https://www.drupal.org/project/commerce_custom_product

This module works great for custom line item types that need to reference a product, however (correct me if I am wrong) this module can't be used to create custom line item types that do NOT reference a product.

I need a custom line item type, that doesn't reference a product. Which lead to the discovery of this:


Utilizing hook_commerce_line_item_type_info() I am able to successfully create a custom line item type, and have it automatically come with the Unit and Total price fields automatically.

All is well so far...

Now if I use the Drupal UI to add a custom field (e.g. an entity reference field, not a product reference field) to this custom line item type, I am able to do this without issue. I can add as many fields as I want.

Now for the problem...

However, when I use the admin order form and try to manually add this custom line item type to an order, the custom field(s) don't show up in the form.

I see from the documentation that I could implement the configuration, add_form and add_form_submit callbacks. But I figured any fields added through the UI would automatically show up on the form(s).

What is going on here? Must I implement the form code-side for all fields on the custom entity type?

  • There is also the (now "deprecated") module Commerce Custom Line Items (Types). It allows to create line item types without product. Worth to give it a try, and see what to do from there.
    – donquixote
    Oct 24, 2015 at 20:40
  • Sorry, just tried myself, it does not really help. Product reference field still there.
    – donquixote
    Oct 24, 2015 at 21:17
  • 1
    It seems you need to manually add widgets for these fields in the add_form callback. Would be nice if we can find a way to automate this.
    – donquixote
    Oct 24, 2015 at 22:18

1 Answer 1


A line item must have a product associated with it. Rules, Commerce Cart, and Commerce Shipping all depend on having the commerce_product field on a line item object.

  • From my testing this a 100% true - however why does hook_commerce_line_item_type_info() have a product boolean?
    – Felix Eve
    Sep 9, 2016 at 5:54
  • 3
    Because a line can be explicitly defined as not a product. A number of modules do this: commerce_account_balance, commerce_exactor, and commerce_payment_split to name 3. Anything that is a product must have the correct fields (from the docs, re: the product boolean attribute): "If set to TRUE, the line item type must also contain the fields added to the base product line item type, commerce_product".
    – nvahalik
    Sep 9, 2016 at 12:45

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.