We would like to add a long text description and an image to each Commerce Discount which we will display to Users.

How do I do this, since the Discount data structures are not available in the Admin?

1 Answer 1


You'll need to implement the field api to attach fields to certain entities. Or you could within hook_entity_info() (I think), there is a 'fieldable' array key you could set to TRUE. From there, you may need to programmatically add a field to it. A good way to get field definition code is to use Field Inspector module, add a field to an entity using the UI, and export that field definition as a base to code yours.

  • THANKS! So are you saying that if one makes the entity 'fieldable' it magically appears in the Admin Content UI so that one can add fields there?
    – jchwebdev
    Feb 18, 2015 at 3:27
  • Not exactly. Since I don't have a site with Commerce Discount on it: if you do a hook-entity-info-alter() and set that to TRUE, if there was already a uri path to manage that discount (think manage fields/manage display), it may allow you to add fields that way. drupal.org/node/1124722 Should explain it better than I.
    – daviedos
    Feb 18, 2015 at 15:26
  • Got it. I see how to add a field programmatically... which seems like a LOT less work than writing all the code just so that I can -then- do the same thing via UI.
    – jchwebdev
    Feb 18, 2015 at 22:35

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.