I posted the relevant code here:
https://pastebin.com/JqFsM1bj
The module that is failing to find the data starts at line 289.
I am running Give 2.3.1
Thanks in advance for any help you can provide.
-
This reply was modified 5 years, 4 months ago by dmnorthcutt.
@dmnorthcutt – Apologies for the delay getting back to you.
I debugged the code and see that the data is being stored as a serialized array within a serialized array via _give_payment_meta
. I’m not sure how exactly this happened but I rewrote the cfa_get_donation_additional_data()
function and it appears to be working properly now via the email tags.
Try replacing the current function you have with this:
function cfa_get_donation_additional_data( $field, $tag_args ) {
$payment_meta = give_get_meta( $tag_args['payment_id'] );
// Checks for legacy serialized data.
if ( isset( $payment_meta['_give_payment_meta'] ) ) {
$payment_meta = maybe_unserialize( $payment_meta['_give_payment_meta'] );
if ( isset( $payment_meta[0] ) ) {
$payment_meta = maybe_unserialize( $payment_meta[0] );
}
}
$output = __( wp_sprintf( 'No %s data found.', $field ), 'give' );
if ( isset( $payment_meta[ $field ] ) && ! empty( $payment_meta[ $field ] ) ) {
$output = $payment_meta[ $field ];
}
return $output;
}
Let me know if that works for you.
Thanks for the reply. When I replaced the function, it caused the page to fail altogether with an HTTP Error 500. When I go back to the old code, the page loads with the old missing data error. Is there something I can do to find out where in the function it is failing now? Thanks.
@dlocc,
Just to clarify, I am using the WP admin dashboard and selecting Donations->settings->Emails, then selecting Preview under the email template in question. With the code I sent, it produces the no-data messages. With the newest code you sent, I get the HTTP Error 500 page back.
Hey @dmnorthcutt – why don’t you ping me via email devin at givewp.com and we can connect via screenshare to sort it out?
Thanks, I will ping you tomorrow morning.