How to debug a Commerce value in Rules if field is not exposed? I use Drupal Commerce with Commerce Credits module to let users buy credits which later can be used to submit content.

The module has support for Rules but I can't get a very simple condition to work. The problem is that 'Entity has credits' rule always returns 0 even if my users have credits:



I tried to debug the amount of user credits but without any results:


Rules evaluation log shows me that comparison to 0 always returns true but to different values always false, independently if user has credits or no. Before that I check if entity is of type node.


Checking if entity is of type commerce_credits and using 'Entity has credits' doesn't give me any result.

Devel debug using action "Debug value" to show credits for user fails for node:author and site:current-user as no reference to credits is shown.
I tried also to get access to commerce_credits by "Fetch entity by id/property", but couldn't figure out what id/property to define.


Looking at the code of Commerce Credits module it looks like credits get saved to an entity called commerce_credits. But I can't figure out how to use this token.

Any other way to debug Rules and find the credits value related to a user?
Looks like you did pretty much everything you can do to &quot;debug&quot; a rule that doesn't seem to do what you want, so I can't give you any other hints to the &quot;how to debug&quot;-part of your questions. But... I may have a solution to get around the actual problem ...
Have a look at the issue &quot;After updating existing content&quot; runs before content is saved, about an event which is a variation of your event here, and somehow explains that &quot;after saving something&quot; actually happens ... &quot;before saving something&quot; (which IMO is not a bug, simply how the Rules module  works ...).
A possible compromise to avoid these kind of issues, is to transform what you're trying to do in your Rules Conditions and -Actions in a Rules Component, so that after your First Rules Action you &quot;schedule the execution&quot; (using the Rules Scheduler submodule) of that Rules Component. For example after only a few seconds or minutes later on (if your cron job runs frequent enough, otherwise it'll be next time cron runs).
BTW, there are also scenarios where it is sufficient to just execute the Rules Component (containing the equivalent of your &quot;subsequent Rules Action&quot;), instead of using the Rules Scheduler to schedule its execution.
Update: as per geraldo's comment below this answer, the actual solution to the question here seems to be as described in comment nr 8 of support issue # 2502703, and which is like so:

The problem is line 317 in commerce_credits.rules.inc. Using count($credits-&gt;credits) always returns 1. Everything works fine when changing it to:
 if ($credits-&gt;credits &gt;= $credit_number) {