0

Let's say I have a content type Order. It has two fields:

Product1 with values 1-10 and Product2 with values 1-10. I am looking for a way to assign prices to the fields.

For example:

Product1*1 = 10

Product1*2 = 20

...

Product2*1 = 20

Product2*2 = 40

So if someone chooses value 2 of Product1 and value 2 of Product2 the system should calculate 40. I will do the calculation with a custom module, I am just looking for a easy way to define these prices.

7
  • Will you only have prices for each product? Are there product pages elsewhere? Commented Aug 22, 2016 at 6:44
  • Which version of Drupal are you using?
    – Raf
    Commented Aug 22, 2016 at 7:32
  • Would the Computed Field module help? Commented Aug 22, 2016 at 7:44
  • I will use prices for each product. There aren't product pages elsewhere. I am using v7. I don't think computed field would work. I would like an easy way for admins to change prices.
    – Chrys
    Commented Aug 24, 2016 at 19:17
  • 2
    the system should calculate 4 , where show him? is another field, please clarify your question, I don't understand what you want to do.
    – Yuseferi
    Commented Aug 28, 2016 at 5:34

2 Answers 2

2

Some solutions you have:

1) create field Product with multi values to content type Order bases on a table field. Module : https://www.drupal.org/project/tablefield

In this table you can attached the prices and with a custom module do the counting.

2) Create content type Order, create content type Product. In content type Product add a field price. Make a relation to entity from Order to Product.

3) Make use of ubercard. This will define products, cards and as far I can remember the recalculation of the card can be refreshed easily

4) Make use of Drupal Commerce, I know it is possible in there but never used it.

Let me know if you need more details.

0

I think I understand what you are trying to do - if you are not using Drupal Commerce, you should be. It will do a lot of this for you, including calculating complex products made of compound attributes. I really would not try to do this with a few content types and fields, something is bound to get missed or you will run into edge cases that Commerce has likely already solved.

You can set up a Commerce site even if users are not doing any on-site checkout just to handle product, pricing, and calculating within its commerce engine, Views, and Rules.

There are lots of contributed price and discount style modules for Commerce, give them a look through and see what could suit you:

https://drupalcommerce.org/taxonomy/term/2564

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.