Okay... The screenshots tell it all.

My use case here was to first, just get an order status updated to something besides pending... then work on the conditions to match before updating status to complete (based on a custom payment method for free products)

Not sure where/what is causing this, I will continue to dig in a bit.

Comments

himerus’s picture

oops.. links in the UL are broken.. refer to attachments below.

himerus’s picture

Title: Rules created via UI do not update order state » Rules do not update order state

This actually seems to be happening by an EXACT duplicate of the default rule in code:

/**
 * Implements hook_default_rules_configuration().
 */

function themegeeks_core_default_rules_configuration() {
  // Store the customer profile entity info for use in default rules.
  $customer_profile_entity_info = entity_get_info('commerce_customer_profile');

  $rules = array();

  // Add a reaction rule to update an order to the default status of the pending
  // order status upon checkout completion.
  $rule = rules_reaction_rule();

  $rule->label = t('ThemeGeeks - Update the order status on checkout completion');
  $rule->active = TRUE;

  $rule
    ->event('commerce_checkout_complete')
    ->action('commerce_order_update_state', array(
      'order:select' => 'order',
      'order_state' => 'completed',
    ));

  $rules['themegeeks_order_status_update'] = $rule;

  return $rules;
}

I've only changed the label text, the order_state value, and the index for the $rules array.
So in testing, this is not working via creating the rule in the interface OR in code.

Not quite sure where this issue should be (Rules or Commerce)

pcambra’s picture

Status: Active » Needs review

Ok, we hit two problems here, one is that the order state for completed misdefine the default order status, thus the labels and defaults get messed up, I'm attaching a patch to solve this.

In the other hand, rules doesn't seem to be respecting the weight for default rules that doesn't define weight and it is executing all them at the end, I've opened a issue in rules queue for this #1083908: Action weight is not considered for default rules with weight 0, but a quick workaround could be to just open & save the default rule, then the weights work fine.

For the patch:
Repo: git.drupal.org:sandbox/pcambra/1081200.git
Branch: 1080764
Diff: http://drupalcode.org/sandbox/pcambra/1081200.git/commitdiff/17d60fa8e8b...

rszrama’s picture

Status: Needs review » Fixed

Committed. That errant whitespace adjustment you made in commerce_order.module caused a merge conflict, though, because I removed that TODO before I committed this patch. It wasn't a problem at all, but it'd be good to keep those tweaks out of general patches. : )

Status: Fixed » Closed (fixed)

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