2

I have 4 stock fields (Stock 1, Stock 2, Stock 3 and TOTAL STOCK) and I want to set up a rule to calculate ["+"] the sum of Stock 1, Stock 2 and Stock 3 fields, and automatically appear in TOTAL STOCK field.

example -> http://ucreateawebsite.com/DRUPAL/dalexgrup/pt

What event, conditions and actions Should I use?

Thank you.

2 Answers 2

3

I found the answer:

For Event I used:

  • After updating an existing commerce product

For Conditions I used:

  • Entity has field

    • Parameter: Entity: [commerce-product], Field: field_stock1
  • Entity has field

    • Parameter: Entity: [commerce-product], Field: field_stock2
  • Entity has field

    • Parameter: Entity: [commerce-product], Field: field_stock3
  • Entity has field

    • Parameter: Entity: [commerce-product], Field: field_totalstock

For Actions I used:

  • Calculate a value

    • Parameter: Input value 1: [commerce-product:field-stock1], Input value 2: [commerce-product:field-stock2]; Provides variables: Calculation result for Stock1 and Stock2 (stock1_plus_stock2_result)
  • Calculate a value

    • Parameter: Input value 1: [stock1-plus-stock2-result], Input value 2: [commerce-product:field-stock3]; Provides variables: Calculation result for stock1-plus-stock2-result and Stock3 (stock1_plus_stock2_result_plus_stock3)
  • Set a data value

    • Parameter: Data: [commerce-product:field-totalstock], Value: [stock1_plus_stock2_result_plus_stock3]

You can see what I wrote on http://ucreateawebsite.com/DRUPAL/dalexgrup/pt.

0

You can try playing with:

Event: on updating content

Conditions: entity has field (to have it available in actions) for stock1, stock2 and stock3

Actions: set data value

1

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.