Last active
December 15, 2017 21:18
-
-
Save joshfeck/9805da8ac5afff20e6ef7d331c79e08b to your computer and use it in GitHub Desktop.
Pass *only* the event name and last related datetime to PayPal (PayPal Express & PayPal Pro) for the order description. Requires Event Espresso 4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
// Event name, venue name, and date | |
add_filter( 'FHEE__EE_Gateway___order_description', | |
'my_custom_order_description_with_date', 10, 3 | |
); | |
function my_custom_order_description_with_date( $desc, $gateway, $payment ) { | |
$desc = 'tickets'; | |
$transaction = $payment->transaction(); | |
if( $transaction instanceof EEI_Transaction ) { | |
$primary_registrant = $transaction->primary_registration(); | |
if( $primary_registrant instanceof EE_Registration ) { | |
$event = $primary_registrant->event_obj(); | |
if ( $event instanceof EEI_Event ) { | |
$desc = $event->name(); | |
$venues = $event->venues(); | |
$venue = reset($venues); | |
if ($venue instanceof EE_Venue) { | |
$desc .= ' at '; | |
$desc .= $venue->name(); | |
} | |
} | |
$datetime = $primary_registrant->get_latest_related_datetime(); | |
if ( $datetime instanceof EE_Datetime ) { | |
$desc .= ' on '; | |
$desc .= $datetime->start_date(); | |
} | |
} | |
} | |
return $desc; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
// event name only | |
add_filter( 'FHEE__EE_Gateway___order_description', | |
'my_custom_order_description', 10, 3 | |
); | |
function my_custom_order_description( $desc, $gateway, $payment ) { | |
$desc = 'Tickets'; | |
$transaction = $payment->transaction(); | |
if( $transaction instanceof EEI_Transaction ) { | |
$primary_registrant = $transaction->primary_registration(); | |
if( $primary_registrant instanceof EE_Registration ) { | |
$event = $primary_registrant->event_obj(); | |
if ( $event instanceof EEI_Event ) { | |
$desc = $event->name(); | |
} | |
} | |
} | |
return $desc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment