Hey Stephen!
I feel like I may be forgetting something obvious, but I cannot figure out with my current configuration (all most recent versions) how to specify which parts of an event are submitted as relevant information in the paypal Item ID and custom info fields. It would be great to know how to control which data gets reported and where.
Also considering adding a custom field that would be an event id code just for the accountant’s use. Any advice about how to best accomplish that?
Thank you, as always.

Ann/Caitlin Wiegand/Everett
Yes, you can use the hook eventorganiser_pre_gateway_checkout_paypal
. E.g.:
function my_alter_paypal_cart( $cart, $booking ){
//$booking is an array. $booking['booking_id'] contains the booking ID
/*
$cart is of the form:
$cart = array(
'return' => //return url
'item_name_0' => //Ticket name,
'amount_0' => //Ticket price
'quantity_0' => //Ticket quantity,
'item_name_1' => //Ticket name (second ticket type),
'amount_1' => //Ticket price (second ticket type),
'quantity_1' => //Ticket quantity (second ticket type),
....
'custom' => //custom data as query variables. e.g. booking_id=X&event_id=Y...
);
*/
//Adjust $cart and return it
return $cart;
}
add_filter( 'eventorganiser_pre_gateway_checkout_paypal', 'my_alter_paypal_cart', 5, 2 );
The custom
key allows you to send extra data to PayPal. However, by default, extra data won’t ‘do’ anything. But should be viewable in PayPal. Please note that the value of the custom
is key is a query string, e.g. field_1=value_1&field_2=vaue_2....
. So if you wish to change the data sent you could do:
//Turn query string into array in $custom
parse_str( $cart['custom'], $custom );
//Alter $custom array. Do not change booking_id!
//Re-build custom query string with the altered $custom array
$cart['custom'] = build_query( $custom );
Note, you should never alter booking_id
, as the plug-in relies on this. By default included data is booking ID, event ID, occurrence ID, (booking) user ID, ticket quantity.
Does that help?

Stephen Harris