Problem:
The two default Rules commerce_registration ships with use the commerce_registration_set_state action to set registration_state to "pending" and "complete," respectively.
Problematically, if you create a custom Rule that uses the commerce_registration_set_state action, the Rule will not set the registration_state because the data structure Rules exports does not match the data structure expected by commerce_registration_set_state() and, not incidentally, the data structure the two default Rules use.
More specifically, commerce_registration_set_state() and the two default Rules expect registration_state to be a string (e.g. "pending") whereas Rules writes registration_state as an array: "registration_state" : { "value" : { "complete" : "complete" } }
.
Proposed solution:
- Update default Rules to match data structure Rules uses to write custom Rules.
- Update line that sets registration_state within commerce_registration_set_state() to expect registration_state to be an array.
Comment | File | Size | Author |
---|---|---|---|
#2 | commerce_registration-custom_commerce_registration_set_state_rules_do_not_set_registration_state-2618372-1.patch | 1.48 KB | caxy4 |
Comments
Comment #2
caxy4 CreditAttribution: caxy4 at ThinkShout commentedAttaching a patch that fixes the described issue using the proposed resolution.
Comment #3
circuscowboy CreditAttribution: circuscowboy commentedThis works as advertised and I agree is major. I don't know when things were changed as this use to work.
Comment #4
drupal-son CreditAttribution: drupal-son commentedI'm having this issue.
I don't see any change after applying the patch.
The rule is firing but the registration state is not updated.
After that, I'm seeing this error:
Warning: strpos() expects parameter 1 to be string, array given in /srv/bindings/f06462d352f2412a86e0e1e8484c408c/code/sites/all/modules/contrib/rules/modules/php.eval.inc on line 21 Warning: strpos() expects parameter 1 to be string, array given in /srv/bindings/f06462d352f2412a86e0e1e8484c408c/code/sites/all/modules/contrib/rules/modules/php.eval.inc on line 24
Is it related?
Any idea?
Many thanks.
Comment #5
drupal-son CreditAttribution: drupal-son commentedUpdate:
I'm also seeing this error on the error log messages:
Warning: reset() expects parameter 1 to be array, string given in commerce_registration_set_state() (line 167 of /srv/bindings/f06462d352f2412a86e0e1e8484c408c/code/sites/all/modules/contrib/commerce_registration/commerce_registration.rules.inc).
I'm running the latest commerce_registration and rules modules.
Comment #6
maddentim CreditAttribution: maddentim commentedI am encountering this issue as well. Need to find solution soon as it is holding up project. I tried the patch but got the same
Warning: reset() expects parameter 1 to be array
as in #5. I am pulling my hair out on this one. I will troubleshoot some more in the morning.
Comment #8
blacklabel_tom CreditAttribution: blacklabel_tom at Edo commented