You are here

function commerce_payment_default_rules_configuration in Commerce Core 7

Implements hook_default_rules_configuration().

File

modules/payment/commerce_payment.rules_defaults.inc, line 11
Default rules configuration for Payment.

Code

function commerce_payment_default_rules_configuration() {
  $rules = array();

  // Add a default rule for each available payment method.
  foreach (commerce_payment_methods() as $method_id => $payment_method) {
    $rule = rules_reaction_rule();
    $rule->label = $payment_method['title'];
    $rule->tags = array(
      'Commerce Payment',
    );
    $rule->active = $payment_method['active'];
    $rule
      ->event('commerce_payment_methods')
      ->action('commerce_payment_enable_' . $method_id, array(
      'commerce_order:select' => 'commerce-order',
      'payment_method' => $method_id,
    ));
    $rules['commerce_payment_' . $method_id] = $rule;
  }
  return $rules;
}