I've added a couple of fields to the standard product bundle included with Commerce, like so:
I'm now trying to add a rule (Data Comparison) based on the "Special Offer Active" field, but for some reason it's missing from the data selector:
The other field I've added ("Special Price") shows up fine.
Anyone know why this might be happening? I've cleared caches a few times and run cron to no avail.
I found the answer in the Commerce documentation:
This is due to the fact that Rules only knows about the default fields that we tell it should function in a manner similar to entity properties. In order to access additional fields, you have to do one of two things in your conditions:
- Use the Entity has field condition to ensure the field you want to access exists on the variable you want to use it for, or
- Use the Data comparison condition to check the type of the entity (i.e. product type) to gain access to every field on the entity.
Using "Content is of type" condition to show all the available field. Besides, install Conditional Rules to enable inline conditional clause.
For anyone who may have the same problem, "Entity has field" didn't work for me but using the "Entity is of bundle" condition did the trick.
The other thing that is a gotcha (of course) is if the field type does not match the type expected. For example, i was mapping fields from node to another entity type. I had a date field in the entity i was mapping to BUT in rules it was stating it had to be a field of type Text. So i tested and sure enough if i made a text field, then it showed after doing the 'entity is of type bundle'.
i had some fields missing with the 'Entity is of bundle' condition but triggering the rule once (updating a node of given bundle in my case) let the field appear in the list.