1

I use "commerce" and "commerce stock" modules, I created a list with products and a few extra fields in Product types: - Image - Deposit 1 Stock - Deposit 2 Stock - Deposit 3 Stock

I created a view (table - http://ucreateawebsite.com/DRUPAL/dalexgrup/pt) with this fields: - Bulk Operations - SKU - Imagine - Title - Deposit 1 Stock - Deposit 2 Stock - Deposit 3 Stock

I have a problem in succeeding to create another stock field (the fourth - called TOTAL STOCK) and making it to automatically update when the other 3 fields are being changed. I want the fourth field to calculate and show me the sum of the other 3 fields.


  • Example 1 *
    Deposit 1 Stock -> 15
    Deposit 2 Stock -> 15

    Deposit 3 Stock -> 15

TOTAL STOCK -> 45


  • Example 2 *
    Deposit 1 Stock -> 10
    Deposit 2 Stock -> 05

    Deposit 3 Stock -> 01

TOTAL STOCK -> 16

This TOTAL STOCK field I should create in Product type like: - Deposit 1 Stock - Deposit 2 Stock - Deposit 3 Stock ??????

Then I should create a rule? What events, conditions and actions I should use?

Thank you.

1 Answer 1

1

I found the answer:

For Event I used:

1. After updating an existing commerce product

For Conditions I used:

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

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

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

4. Entity has field - Parameter: Entity: [commerce-product], Field: field_totalstock

For Actions I used:

1. 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)

2. 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)

3. Set a data value - Parameter: Data: [commerce-product:field-totalstock], Value: [stock1_plus_stock2_result_plus_stock3]

You can see what I wrote here -> http://ucreateawebsite.com/DRUPAL/dalexgrup/pt

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.