-
Notifications
You must be signed in to change notification settings - Fork 3
/
commerce_license_billing.rules_defaults.inc
104 lines (101 loc) · 3.96 KB
/
commerce_license_billing.rules_defaults.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* @file
* Default rule configurations for Commerce License Billing.
*/
/**
* Implements hook_default_rules_configuration().
*/
function commerce_license_billing_default_rules_configuration() {
$items = array();
$items['commerce_license_billing_set_postpaid_product_price'] = entity_import('rules_config', '{ "commerce_license_billing_set_postpaid_product_price" : {
"LABEL" : "Set the price of postpaid products to 0",
"PLUGIN" : "reaction rule",
"TAGS" : [ "Commerce License Billing" ],
"REQUIRES" : [ "rules", "commerce_license_billing", "commerce_product_reference" ],
"ON" : [ "commerce_product_calculate_sell_price" ],
"IF" : [
{ "NOT entity_is_of_bundle" : {
"entity" : [ "commerce-line-item" ],
"type" : "commerce_line_item",
"bundle" : { "value" : { "recurring" : "recurring" } }
}
},
{ "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
{ "commerce_license_billing_product_is_postpaid" : { "commerce_product" : [ "commerce-line-item:commerce-product" ] } }
],
"DO" : [
{ "commerce_line_item_unit_price_amount" : {
"commerce_line_item" : [ "commerce_line_item" ],
"amount" : "0",
"component_name" : "base_price",
"round_mode" : "0"
}
}
]
}
}');
$items['commerce_license_billing_create_recurring_orders'] = entity_import('rules_config', '{ "commerce_license_billing_create_recurring_orders" : {
"LABEL" : "Create recurring orders based on the initial order",
"PLUGIN" : "reaction rule",
"WEIGHT" : "10",
"TAGS" : [ "Commerce License Billing" ],
"REQUIRES" : [ "commerce_license_billing", "commerce_payment" ],
"ON" : [ "commerce_payment_order_paid_in_full" ],
"IF" : [
{ "commerce_license_billing_order_elligible" : { "commerce_order" : [ "commerce_order" ] } }
],
"DO" : [
{ "commerce_license_billing_create_recurring_orders" : { "commerce_order" : [ "commerce_order" ] } }
]
}
}');
// For some reason, a crash occurs if the cardonfile module is missing when
// adding a default rule with it as the dependency.
if (module_exists('commerce_cardonfile')) {
$items['rules_commerce_license_billing_charge_recurring_order'] = entity_import('rules_config', '{ "rules_commerce_license_billing_charge_recurring_order" : {
"LABEL" : "Charge a recurring order",
"PLUGIN" : "reaction rule",
"TAGS" : [ "Commerce License Billing" ],
"REQUIRES" : [ "rules", "commerce_payment", "commerce_cardonfile", "entity" ],
"ON" : [ "commerce_order_update" ],
"IF" : [
{ "NOT data_is" : {
"data" : [ "commerce-order:status" ],
"value" : [ "commerce-order-unchanged:status" ]
}
},
{ "data_is" : {
"data" : [ "commerce-order:status" ],
"value" : "recurring_payment_pending"
}
},
{ "commerce_payment_order_balance_comparison" : {
"commerce_order" : [ "commerce_order" ],
"operator" : "\u003E",
"value" : "0"
}
}
],
"DO" : [
{ "commerce_cardonfile_order_select_card" : {
"USING" : { "order" : [ "commerce-order" ] },
"PROVIDE" : { "select_card_response" : { "select_card_response" : "Select card response" } }
}
},
{ "commerce_cardonfile_order_charge_card" : {
"USING" : {
"order" : [ "commerce-order" ],
"charge" : [ "" ],
"select_card_response" : [ "select_card_response" ],
"card_data" : [ "" ]
},
"PROVIDE" : { "charge_card_response" : { "charge_card_response" : "charge Card Response" } }
}
}
]
}
}');
}
return $items;
}