Any idea how to access a Variable created in another rule. I am trying to use the Data Comparison in the conditions section. Is doing this even possible or are Variables only visible within the Rule they were created?



The variable you created in one rule will not automatically be available to other rules.

However, if there is a rule that creates a variable that you may need to reuse frequently, one thing you can do is create it as a rules component. Then you can reuse that setup multiple times. It can also keep your rules leaner and cleaner!

  • I will give that a try tomorrow when I am not so tired and the misty vale of wine has evaporated. But are you saying that variables set in rules components will keep their values throughout the users session and can be accessed by other components? – PrestonDocks Feb 2 '13 at 23:31
  • 1
    You can make a component called a Rules set. Variables set in a rules set will be valid for as long as the Rules set is being processed, not the entire user session. – Patrick Kenny Feb 3 '13 at 0:52
  • So the question then is how can I get a variable to stay valid for the life of the users session. The first time a user adds a product to a commerce cart I create and assign a variable with a taxonomy termid associated with the product. For further products added to the cart I check that the term id is the same. Some products have different ID's and customers are not allowed to mix and match. – PrestonDocks Feb 3 '13 at 11:10
  • Can't you just evaluate the customer's cart at checkout then, when you have all the products at once to check against each other? – Boriana Ditcheva Feb 3 '13 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.