Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created November 3, 2015 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/84da7e1ba6bd4b772244 to your computer and use it in GitHub Desktop.
Save joshfeck/84da7e1ba6bd4b772244 to your computer and use it in GitHub Desktop.
<?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