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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

caxy4 created an issue. See original summary.

caxy4’s picture

Attaching a patch that fixes the described issue using the proposed resolution.

circuscowboy’s picture

Status: Active » Reviewed & tested by the community

This works as advertised and I agree is major. I don't know when things were changed as this use to work.

drupal-son’s picture

I'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.

drupal-son’s picture

Update:

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.

maddentim’s picture

I 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.

  • blacklabel_tom committed 3f92c1f on 7.x-2.x authored by caxy4
    Issue #2618372 by caxy4: custom commerce_registration_set_state rules do...
blacklabel_tom’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.