forked from ds-festival/event_espresso_4_custom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathespresso_custom.php
54 lines (43 loc) · 2.05 KB
/
espresso_custom.php
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
function espresso_track_successful_sale_manual( $Transaction, $status_updates ){
if ($Transaction instanceof EE_Transaction) {
$sale_amt = $Transaction->paid();
$unique_transaction_id = $Transaction->ID();
$Primary_Registration = $Transaction->primary_registration();
if ($Primary_Registration instanceof EE_Registration) {
$Attendee = $Primary_Registration->attendee();
if ($Attendee instanceof EE_Attendee) {
$email = $Attendee->email();
$referrer = $_COOKIE['ap_id'];
//throw new Exception("Sale amount: ".$sale_amt.", " .
// "unique_transaction_id: ".$unique_transaction_id.", " .
// "email: ".$email.", " .
// "referrer: ".$referrer.", "
// , 1);
do_action('wp_affiliate_process_cart_commission', array("referrer" => $referrer, "sale_amt" =>$sale_amt, "txn_id"=>$unique_transaction_id, "buyer_email"=>$email));
}
}
}
}
add_action('AHEE__EE_Transaction_Processor__manually_update_registration_statuses','espresso_track_successful_sale_manual', 20, 2);
function espresso_track_successful_sale_gateway( $Transaction, $status_updates ){
//throw new Exception("BROKEN");
if ($Transaction instanceof EE_Transaction) {
$sale_amt = $Transaction->paid();
$unique_transaction_id = $Transaction->ID();
$Primary_Registration = $Transaction->primary_registration();
if ($Primary_Registration instanceof EE_Registration) {
$Attendee = $Primary_Registration->attendee();
if ($Attendee instanceof EE_Attendee) {
$email = $Attendee->email();
$referrer = $_COOKIE['ap_id'];
//throw new Exception("Sale amount: ".$sale_amt.", " .
// "unique_transaction_id: ".$unique_transaction_id.", " .
// "email: ".$email.", " .
// "referrer: ".$referrer.", "
// , 1);
do_action('wp_affiliate_process_cart_commission', array("referrer" => $referrer, "sale_amt" =>$sale_amt, "txn_id"=>$unique_transaction_id, "buyer_email"=>$email));
}
}
}
}
add_action('AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment','espresso_track_successful_sale_gateway', 20, 2);