Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pass *only* the event name and last related datetime to PayPal (PayPal Express & PayPal Pro) for the order description. Requires Event Espresso 4.
<?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;
}
<?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
You can’t perform that action at this time.