home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (uc_payment.rules_defaults.inc)

This example Drupal source code file (uc_payment.rules_defaults.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, configs, full, function, negate, order, order:select, order_status, payment, php, rule, rules_reaction_rule, status, true

The uc_payment.rules_defaults.inc Drupal example source code

<?php

/**
 * @file
 * Default rules configurations.
 */

/**
 * Implements hook_default_rules_configuration().
 */
function uc_payment_default_rules_configuration() {
  $configs = array();

  // Set the order status to "Payment Received" when a payment is received
  // and the balance is less than or equal to 0.
  $rule = rules_reaction_rule();
  $rule->label = t('Update order status on full payment');
  $rule->active = TRUE;
  $rule->event('uc_payment_entered')
    ->condition('uc_payment_condition_order_balance', array(
      'order:select' => 'order',
      'balance_comparison' => 'less_equal',
    ))
    ->condition(rules_condition('data_is', array(
        'data:select' => 'order:order-status',
        'value' => 'payment_received',
      ))
      ->negate())
    ->action('uc_order_update_status', array(
      'order:select' => 'order',
      'order_status' => 'payment_received',
    ));
  $configs['uc_payment_received'] = $rule;

  // Set the order status to "Completed" when checkout is complete, none
  // of the products are shippable, and the balance is less than or equal to 0.
  $rule = rules_reaction_rule();
  $rule->label = t('Update order status upon checkout completion with full payment');
  $rule->active = TRUE;
  $rule->event('uc_checkout_complete')
    ->condition('uc_payment_condition_order_balance', array(
      'order:select' => 'order',
      'balance_comparison' => 'less_equal',
    ))
    ->condition(rules_condition('uc_order_condition_is_shippable', array(
        'order:select' => 'order',
      ))
      ->negate())
    ->action('uc_order_update_status', array(
      'order:select' => 'order',
      'order_status' => 'completed',
    ));
  $configs['uc_checkout_complete_paid'] = $rule;

  return $configs;
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal uc_payment.rules_defaults.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.