You are here

function commerce_recurring_default_rules_configuration in Commerce Recurring Framework 7

Same name and namespace in other branches
  1. 7.2 commerce_recurring.rules_defaults.inc \commerce_recurring_default_rules_configuration()

Implementation of hook_default_rules_configuration().

File

./commerce_recurring.rules_defaults.inc, line 13

Code

function commerce_recurring_default_rules_configuration() {
  $items = array();
  $items['commerce_recurring_process_orders'] = entity_import('rules_config', '{ "commerce_recurring_process_orders" : {
      "LABEL" : "Generate Recurring Orders",
      "PLUGIN" : "reaction rule",
      "TAGS" : [ "Commerce Recurring" ],
      "REQUIRES" : [ "commerce_recurring", "rules" ],
      "ON" : [ "cron" ],
      "DO" : [
        { "commerce_recurring_load_recurring" : { "PROVIDE" : { "orders" : { "orders" : "Recurring Orders" } } } },
        { "LOOP" : {
            "USING" : { "list" : [ "orders" ] },
            "ITEM" : { "order" : "Order" },
            "DO" : [
              { "component_commerce_recurring_generate_orders" : { "order" : [ "order" ] } }
            ]
          }
        }
      ]
    }
  }');
  $items['commerce_recurring_generate_orders'] = entity_import('rules_config', '{ "commerce_recurring_generate_orders" : {
      "LABEL" : "Generate Recurring Order if Appropriate",
      "PLUGIN" : "rule",
      "REQUIRES" : [ "commerce_recurring" ],
      "USES VARIABLES" : { "order" : { "label" : "Order", "type" : "commerce_order" } },
      "IF" : [
        { "commerce_recurring_rules_order_contains_recurring" : { "commerce_order" : [ "order" ] } },
        { "commerce_recurring_rules_order_is_master" : { "commerce_order" : [ "order" ] } }
      ],
      "DO" : [
        { "commerce_recurring_process_recurring" : {
            "USING" : { "commerce_order" : [ "order" ] },
            "PROVIDE" : { "recurring_order" : { "recurring_order" : "New Order" } }
          }
        }
      ]
    }
  }');
  $items['commerce_recurring_initialise_order_master'] = entity_import('rules_config', '{ "commerce_recurring_initialise_order_master" : {
      "LABEL" : "Set First Repeat date of Recurring Order",
      "PLUGIN" : "reaction rule",
      "TAGS" : [ "Commerce Recurring" ],
      "REQUIRES" : [ "commerce_recurring", "rules", "commerce_checkout" ],
      "ON" : [ "commerce_checkout_complete" ],
      "IF" : [
        { "commerce_recurring_rules_order_contains_recurring" : { "commerce_order" : [ "commerce_order" ] } }
      ],
      "DO" : [
        { "commerce_recurring_initialise_recurring" : {
            "USING" : { "commerce_order" : [ "commerce_order" ] }
          }
        }
      ]
    }
  }');
  $items['commerce_recurring_trigger_payments'] = entity_import('rules_config', '{ "commerce_recurring_trigger_payments" : {
      "LABEL" : "Trigger Payments against recurring orders",
      "PLUGIN" : "reaction rule",
      "REQUIRES" : [ "commerce_recurring", "rules" ],
      "ON" : [ "cron" ],
      "DO" : [
        { "commerce_recurring_load_payments_due" : { "PROVIDE" : { "orders" : { "orders" : "Recurring Orders" } } } },
        { "LOOP" : {
            "USING" : { "list" : [ "orders" ] },
            "ITEM" : { "order" : "Current Order" },
            "DO" : [
              { "commerce_recurring_process_payment" : { "commerce_order" : [ "order" ] } }
            ]
          }
        }
      ]
    }
  }');
  return $items;
}