Created
October 12, 2020 15:48
-
-
Save Pebblo/727a4005e3247754e5787cdffa4a269e to your computer and use it in GitHub Desktop.
Example of to change the defautl gateway order description to use an itemized list of '{ticket name} x {qty}'
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 if you already have one | |
add_filter( 'FHEE__EE_Gateway___order_description', | |
'tw_ee_itemized_tickets_description', 10, 3 | |
); | |
function tw_ee_itemized_tickets_description( $desc, $gateway, $payment ) { | |
$desc_array = array(); | |
$txn = $payment->transaction(); | |
$ticket_line_items = EEH_Line_Item::get_ticket_line_items($txn->total_line_item()); | |
foreach($ticket_line_items as $ticket_line_item) { | |
if( $ticket_line_item instanceof EE_Line_Item) { | |
$desc_array[] = $ticket_line_item->name() . ' x ' . $ticket_line_item->quantity(); | |
} | |
} | |
if( !empty($desc_array) ) { | |
return implode(", ", $desc_array); | |
} | |
return $desc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment