I need help understanding data selectors


I help run an online course registration/payment system for a small college. We're currently using Ubercart, but I think a redesign of our store coupled with DrupalCommerce and its integration with Rules will solve some of the issues we're having.

In particular, I want to keep the user from being able to accidentally do some things like overbook themselves (sign up for two classes that meet at the same time).

I think I might be able to do this with Rules. When the customer tries to add an item to their cart I want to check to see if they already have an item in their cart that meets at the same time slot.

But in order to do that I really need to understand data selectors better. I have searched high and low, and maybe I just missed something, but I cannot find a good explanation of data selectors. Any help would be hugely appreciated.


Posted: Aug 26, 2011


trevorkjorlien on September 3, 2011

Did you find a link or a set of tutorials explaining them better?

I think I'm getting the hang of them, but other people are probably equally lost.

steenbob on September 7, 2011

For those asking about what got me unstuck, it was the reply I got about the same question over on the Drupal groups site.

Here's the link:

It helps if you have a solid programming background, but basically you can think of data selectors as a way of referencing the publicly exposed elements of, say, a .NET class.

The thing is, some objects that you're trying to manipulate in Rules can belong to several "classes" and you can only get to certain elements if Rules has been able to "cast" your object as the correct "class." This is done through conditional statements that basically say something along the lines of "Only continue if the object is of this class."

Rules doesn't quite use that same vocabulary, but it's along those lines.