I am using Drupal 7 and Commerce.

I have Product display where is custom field called Stock (field_stock). This field holds stock value (integer) for Product.

In Product display I have Product Variations. Variations has custom field called Stock Value (field_stock_value).

When adding new Product display and setting field Stock to value 10. And then adding first Variation and setting field Stock Value to 6. And to second Variation field Stock Value to 4.

I need to have rules which decreases Stock field from Product display. So it is simple: take value from Stock Value field and reduce that amount from Stock field.

But I have not succeeded to make working rules for that. Any help needed. Thanks!

  • The main problem here is that I cant get field_stock to show in Actions. Because cant add condition "Content is type of" because there is no Node data selector. And that is because I have to have Event "Completing the checkout process"
    – hene
    Commented Mar 17, 2013 at 9:39
  • I think I understand your missing event challenge. However, when you're "adding a variation" (1st or 2nd, doesn't matter), what kind of information (which fields, ie their machine names) do you have available that indicate which "product display" that variation is about (related to)? Commented Feb 6, 2017 at 15:20

1 Answer 1


Try Computed Field

Computed Field is a very powerful CCK field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of CCK fields. So start cooking up your PHP based values!

Check Conditional Fields too

Define dependencies between fields based on their states and values.

  • none of these solutions are work!!
    – shekoufeh
    Commented Jun 25, 2015 at 4:17

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.