Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php //Please do add the opening PHP tag if you already have one.
- function tw_ee_only_check_payment_method_based_on_ticket_name($payment_methods, $transaction, $scope) {
- //Double check we have a transaction object.
- if ( $transaction instanceof EE_Transaction) {
- //Initialize an array used to hold the ticket names.
- $ticket_names = array();
- //Loop over all registrations and add the ticket name for each reg to the ticket_names array.
- foreach( $transaction->registrations() as $registration ) {
- $ticket_names[] = $registration->ticket()->name();
- }
- //Loop over ticket_names, if any of them have 'check' in the name then pull a check payment method and return only that.
- foreach($ticket_names as $ticket_name){
- if (strpos($ticket_name, 'check') !== false) {
- $check_payment_method = EEM_Payment_Method::instance()->get_one_of_type( 'Check' );
- if( $check_payment_method instanceof EE_Payment_Method) {
- $payment_methods = array();
- $payment_methods[] = $check_payment_method;
- break;
- }
- }
- }
- }
- return $payment_methods;
- }
- add_filter('FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods', 'tw_ee_only_check_payment_method_based_on_ticket_name', 20, 3 );
Add Comment
Please, Sign In to add comment