Hi,
I just installed the latest version of Rules, and I have been trying the stuff that I can do with It.
But for a couple of hours I haven't been able to fix/find the right way to do what I want.
What I want to do is to fetch the current value of a term field, and then calculate it with other value.
This is the example:
I have a node type called products. The node have a price field (without a currency). It is just a integer field.
Then I created a field for my taxonomy (currency taxonomy) with the values of the exchange rate:
ex: EUR: 0,45
US : 0,24
ARG: 1
What I would like to do is to calculate the number of that exchange field with the price field, so I will get a value
that would be: [price-field] * [exchange-of-the-selected-term] = New Value [ X ARG]
How would that be possible?
Thank you in advance.
Comments
I wasn't able to fetch
I wasn't able to fetch taxonomy field either but you can fetch user fields easily. Create a user account and name it something like Company Account. Add exchange field to user entity under user accounts. This field can be set to only be viewed by users, even author. This way a regular user never see's this field. Or you could allow each user to insert their own exhange rate.
In rules, fetch entity by ID. Select user. enter in the id number of the Company Account, (can be found in phpmyadmin).
Now you will have access to all user fields, and the specific data value in any of the fields from the Company Account.
When a product transaction takes place you can reference the company-account-exchange-field-value and then add, subtract, convert, set data value, etc to the current product field.
If you need more than one exchange value, when you create the exchange field, set it to unlimited values. This will allow you to add as many values as you want to that field for a specific user. Remember no regular user will see this in their settings.
You can simply go to your company account under edit settings and then add as many different values as you want. They will be listed in the database as delta values, delta0, delta1, delta2, etc. Rules will allow you to specify which delta you want.
Provided you do not set any default value for this field, no extra data will be created in any new user accounts.
Thank you very much for your
Thank you very much for your help, but It was actually possible to do using data to compare, and then selecting the fields that I wanted to fetch.
Thanks again anyway, It was a possible solution