| 1 |
|
<?php |
| 2 |
|
// $Id: $ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* @file |
| 6 |
|
* This file contains the Conditional Actions hooks and functions necessary to make the |
| 7 |
|
* order related entity, conditions, events, and actions work. |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
|
|
| 11 |
|
/****************************************************************************** |
| 12 |
|
* Conditional Actions Hooks * |
| 13 |
|
******************************************************************************/ |
| 14 |
|
|
| 15 |
|
/** |
| 16 |
|
* Implementation of hook_ca_trigger. |
| 17 |
|
* Tell Ubercart about the various setcom triggers. |
| 18 |
|
*/ |
| 19 |
|
function uc_setcom_ca_trigger() { |
| 20 |
|
$order_arg = array('#entity' => 'uc_order', '#label' => t('Order')); |
| 21 |
|
|
| 22 |
|
$triggers['setcom_payment_received'] = array( |
| 23 |
|
'#title' => t('Payment received'), |
| 24 |
|
'#category' => t('Setcom'), |
| 25 |
|
'#arguments' => array( |
| 26 |
|
'order' => $order_arg, |
| 27 |
|
'account' => array('#entity' => 'user', '#label' => t('customer user account')) |
| 28 |
|
), |
| 29 |
|
); |
| 30 |
|
|
| 31 |
|
$triggers['setcom_payment_pending'] = array( |
| 32 |
|
'#title' => t('Payment pending'), |
| 33 |
|
'#category' => t('Setcom'), |
| 34 |
|
'#arguments' => array( |
| 35 |
|
'order' => $order_arg, |
| 36 |
|
'account' => array('#entity' => 'user', '#label' => t('customer user account')) |
| 37 |
|
), |
| 38 |
|
); |
| 39 |
|
|
| 40 |
|
$triggers['setcom_payment_denied'] = array( |
| 41 |
|
'#title' => t('Payment denied'), |
| 42 |
|
'#category' => t('Setcom'), |
| 43 |
|
'#arguments' => array( |
| 44 |
|
'order' => $order_arg, |
| 45 |
|
'account' => array('#entity' => 'user', '#label' => t('customer user account')) |
| 46 |
|
), |
| 47 |
|
); |
| 48 |
|
return $triggers; |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
/** |
| 52 |
|
* Implementation of hook_ca_predicate) |
| 53 |
|
*/ |
| 54 |
|
function uc_setcom_ca_predicate() { |
| 55 |
|
$configurations = array(); |
| 56 |
|
$configurations['uc_setcom_payment_received'] = array( |
| 57 |
|
'#title' => t('Update order status on Setcom full payment'), |
| 58 |
|
'#description' => t('Only happens when a Setcom transaction was successful.'), |
| 59 |
|
'#class' => 'setcom', |
| 60 |
|
'#trigger' => 'setcom_payment_received', |
| 61 |
|
'#status' => 1, |
| 62 |
|
'#conditions' => array( |
| 63 |
|
'#operator' => 'AND', |
| 64 |
|
'#conditions' => array( |
| 65 |
|
array( |
| 66 |
|
'#name' => 'uc_order_status_condition', |
| 67 |
|
'#title' => t('Check if the order status is pending.'), |
| 68 |
|
'#argument_map' => array( |
| 69 |
|
'order' => 'order', |
| 70 |
|
), |
| 71 |
|
'#settings' => array( |
| 72 |
|
'negate' => FALSE, |
| 73 |
|
'order_status' => 'pending', |
| 74 |
|
), |
| 75 |
|
), |
| 76 |
|
), |
| 77 |
|
), |
| 78 |
|
'#actions' => array( |
| 79 |
|
array( |
| 80 |
|
'#name' => 'uc_order_update_status', |
| 81 |
|
'#title' => t('Update the order status to Payment Received.'), |
| 82 |
|
'#argument_map' => array( |
| 83 |
|
'order' => 'order', |
| 84 |
|
), |
| 85 |
|
'#settings' => array( |
| 86 |
|
'order_status' => 'setcom_payment_received', |
| 87 |
|
), |
| 88 |
|
), |
| 89 |
|
), |
| 90 |
|
); |
| 91 |
|
|
| 92 |
|
$configurations['uc_setcom_payment_pending'] = array( |
| 93 |
|
'#title' => t('Update order status on Setcom payment pending'), |
| 94 |
|
'#description' => t('Only happens when a Setcom transaction was not completed. Most probably when payment must first be cleared.'), |
| 95 |
|
'#class' => 'setcom', |
| 96 |
|
'#trigger' => 'setcom_payment_pending', |
| 97 |
|
'#status' => 1, |
| 98 |
|
'#conditions' => array( |
| 99 |
|
'#operator' => 'AND', |
| 100 |
|
'#conditions' => array( |
| 101 |
|
array( |
| 102 |
|
'#name' => 'uc_order_status_condition', |
| 103 |
|
'#title' => t('If the order status is pending.'), |
| 104 |
|
'#argument_map' => array( |
| 105 |
|
'order' => 'order', |
| 106 |
|
), |
| 107 |
|
'#settings' => array( |
| 108 |
|
'negate' => FALSE, |
| 109 |
|
'order_status' => 'pending', |
| 110 |
|
), |
| 111 |
|
), |
| 112 |
|
), |
| 113 |
|
), |
| 114 |
|
'#actions' => array( |
| 115 |
|
array( |
| 116 |
|
'#name' => 'uc_order_update_status', |
| 117 |
|
'#title' => t('Update the order status to Payment Received.'), |
| 118 |
|
'#argument_map' => array( |
| 119 |
|
'order' => 'order', |
| 120 |
|
), |
| 121 |
|
'#settings' => array( |
| 122 |
|
'order_status' => 'setcom_payment_pending', |
| 123 |
|
), |
| 124 |
|
), |
| 125 |
|
), |
| 126 |
|
); |
| 127 |
|
|
| 128 |
|
$configurations['uc_setcom_payment_denied'] = array( |
| 129 |
|
'#title' => t('Set order status to payment denied by Setcom'), |
| 130 |
|
'#description' => t('Only happens when a Setcom transaction was not successful.'), |
| 131 |
|
'#class' => 'setcom', |
| 132 |
|
'#trigger' => 'setcom_payment_denied', |
| 133 |
|
'#status' => 1, |
| 134 |
|
'#conditions' => array( |
| 135 |
|
'#operator' => 'AND', |
| 136 |
|
'#conditions' => array( |
| 137 |
|
array( |
| 138 |
|
'#name' => 'uc_order_status_condition', |
| 139 |
|
'#title' => t('If the order status is pending.'), |
| 140 |
|
'#argument_map' => array( |
| 141 |
|
'order' => 'order', |
| 142 |
|
), |
| 143 |
|
'#settings' => array( |
| 144 |
|
'negate' => FALSE, |
| 145 |
|
'order_status' => 'pending', |
| 146 |
|
), |
| 147 |
|
), |
| 148 |
|
), |
| 149 |
|
), |
| 150 |
|
'#actions' => array( |
| 151 |
|
array( |
| 152 |
|
'#name' => 'uc_order_update_status', |
| 153 |
|
'#title' => t('Update the order status to Payment Denied.'), |
| 154 |
|
'#argument_map' => array( |
| 155 |
|
'order' => 'order', |
| 156 |
|
), |
| 157 |
|
'#settings' => array( |
| 158 |
|
'order_status' => 'setcom_payment_denied', |
| 159 |
|
), |
| 160 |
|
), |
| 161 |
|
), |
| 162 |
|
); |
| 163 |
|
return $configurations; |
| 164 |
|
} |