-
-
Save joshfeck/84da7e1ba6bd4b772244 to your computer and use it in GitHub Desktop.
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 | |
add_filter( 'FHEE__EEG_Paypal_Standard__set_redirection_info__arguments', 'jf_ee_add_paypal_item_id' ); | |
function jf_ee_add_paypal_item_id( $redirect_args ) { | |
if ( ! defined( 'EE_MER_PATH' ) ) { | |
$checkout = EE_Registry::instance()->SSN->checkout(); | |
if ( $checkout instanceof EE_Checkout ) { | |
$transaction = $checkout->transaction; | |
if ( $transaction instanceof EE_Transaction ) { | |
foreach ( $transaction->registrations() as $registration ) { | |
if ( $registration instanceof EE_Registration ) { | |
$event = $registration->event(); | |
if ( $event instanceof EE_Event ) { | |
$meta_key_value = get_post_meta( $event->ID(), 'paypal_item_id', true ); | |
if ( ! empty( $meta_key_value ) ) { | |
$redirect_args[ 'item_number_1' ] = $meta_key_value; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
return $redirect_args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment