I have a content type of product, and want to set the postage cost for the item which is dependent upon length,width,height, weight but also product kind - e.g. hazardous items needing special courier etc. I have a series of prices for the various weights and size limits, so I'm wondering how can I utilise these prices for the postage field automatically.

At the moment, the prices aren't inserted in Drupal, would these prices be better as a separate content-type or as fields inside a courier content-type? If the latter would they be as easy to reference?

This is not for a commerce site, merely somewhere to manage all my stock from all the various suppliers - a product information manager.


If you have a small number of settings to store, you might consider using system_settings_form() to store them in Drupal's variables table. Take a look at the core modules that implement this function for more examples.

If the rates group logically, and/or need to be edited by users, you might make a postage_rates content type with fields on that for the information that changes in addition to any constants set by an admin using the first method. You can then add a entityreference field from you product to the postage_rate.

  • Is it possible for the postage value to be shown / calculated dynamically? I don't intend to add entity references to a considerable amount of products, and if weight limits change in the future, I wouldn't have to change xxx,xxx hard-coded references! – user3791372 Nov 10 '14 at 10:44
  • Certainly. The point of my suggestion is to avoid creating a maintenance problem by placing the postage rates directly into your code. You can calculate and set a field value in hook_node_presave() using an entity wrapper. – FatherShawn Nov 11 '14 at 18:41

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.