Payment description
-
Is it possible to change the Mollie payment description. Now this is:Reservering voor ‘EVENT DESCRIPTION’.
I need the name of the booker in the payment description.
-
Gateway is Mollie.
No bug found for mollie (on first glance). Are you sure your code is being executed? Did you add that code to your theme’s functions.php?
Yes, the same way I added the rsvp form filter. Priority of both is set to 10, is that a possible problem?
In filter:
function my_eme_rsvp_payment_descr($description,$payment,$gateway_name)In eme_payments.php:
$name=apply_filters($filtername,$name,$payment,$gateway);Is this ok?
There’s nothing wrong with that.
Ok, this pops up using your code in the php error log:
[11-Jan-2019 22:18:48 UTC] PHP Notice: Trying to get property ‘lastname’ of non-object in /var/www/html/wordpress/wp-content/themes/twentyseventeen/functions.php on line 618
[11-Jan-2019 22:18:48 UTC] PHP Notice: Trying to get property ‘firstname’ of non-object in /var/www/html/wordpress/wp-content/themes/twentyseventeen/functions.php on line 619
[11-Jan-2019 22:18:48 UTC] PHP Notice: Trying to get property ‘event_name’ of non-object in /var/www/html/wordpress/wp-content/themes/twentyseventeen/functions.php on line 620So: you should’ve reported that and also mentioned that the description was replaced partially. That’s also why I asked you to do a print_r on the variables …
This is the correct code:
function my_eme_rsvp_payment_descr($description,$payment,$gateway_name) { $booking_ids = eme_get_payment_booking_ids($payment['id']); $booking = eme_get_booking($booking_ids[0]); $event = eme_get_event($booking['event_id']); $person = eme_get_person($booking['person_id']); $lastname = $person['lastname']; $firstname = $person['firstname']; $evenement = $event['event_name']; $description = "Betaling van $firstname $lastname voor $evenement"; return $description; } add_filter('eme_rsvp_paymentform_description_filter','my_eme_rsvp_payment_descr',10,3);
Thanks a lot for your’e response. I wasn’t able (yesterday) to reach the php log files. Also the description was not changed partially, nothing was changed on the description.
i have used the new code and it is still not working. The description is unchanged. (sorry, I have no access to the PHP log files. I will contact the hosting provider next week)
print_r ($description); doesn’t show anything.
function my_eme_rsvp_payment_descr($description,$payment,$gateway_name) { $booking_ids = eme_get_payment_booking_ids($payment['id']); $booking = eme_get_booking($booking_ids[0]); $event = eme_get_event($booking['event_id']); $person = eme_get_person($booking['person_id']); $lastname = $person['lastname']; $firstname = $person['firstname']; $evenement = $event['event_name']; $description = "Betaling van $firstname $lastname voor $evenement"; print_r ($description); return $description; } add_filter('eme_rsvp_paymentform_description_filter','my_eme_rsvp_payment_descr',10,3);
The code I posted has been tested (on Stripe) and works as designed. Again: are you sure the code is being executed? If print_r($description) is in your code, normally the booking will end in an error (“An error has occured”) because of course it is not an expected ajax answer from the server. But your browser network console should then show the text for that request in the reply.
Response admin-ajax.php:
Betaling van Patrick van Wijk voor TEST{“Result”:”OK”,”keep_form”:0,”htmlmessage”:”LET OP:<\/strong><br \/>\n<br \/>\nMoet er voor je inschrijving betaald worden:<br \/>\nJe inschrijving is opgeslagen maar nog niet definitief. Na ontvangst van je betaling is je inschrijving pas definitief.<\/em><br \/>\n<br \/>\nBetaal je inschrijving direct met iDeal door hieronder op de betaalknop te klikken.<\/strong>”,”paymentform”:”<div id=’eme-payment-handling’ class=’eme-payment-handling’>Afhandelen betaling<\/div><div id=’eme-payment-price-info’ class=’eme-payment-price-info’>De prijs in EUR is: 1.00<\/div><div id=’eme-payment-form’ class=’eme-payment-form’><br \/><form action=’https:\/\/www.mollie.com\/paymentscreen\/issuer\/select\/ideal\/CMbwGQNnBT’ method=’get’><input type=’submit’ value=’BETALEN’ \/><br \/>
<\/form><\/div>”}
I have placed the filter in the top of my functions.php and now it seems to work.
The admin-ajax response seems to indicate that the filter is working fine.
Which other own filters do you have defined in your functions.php?This was the none working code:
<?php add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } /** * Remove the href from empty links <code><a href="#"></code> in the nav menus * @param string $menu the current menu HTML * @return string the modified menu HTML */ function wpse_remove_empty_links( $menu ) { return str_replace( '<a href="#">', '<a>', $menu ); } add_filter( 'wp_nav_menu_items', 'wpse_remove_empty_links' ); add_filter('show_admin_bar', '__return_false'); /** * Change Default Display Name (Powered by yeahhub.com) */ function change_display_name( $user_id ) { $info = get_userdata( $user_id ); $args = array( 'ID' => $user_id, 'display_name' => $info->first_name . ' ' . $info->last_name ); wp_update_user( $args ); } add_action('user_register','change_display_name'); function my_formfield_filter($formfield,$postfield_name,$value) { // do a print_r of $formfield, etc ... to see the content. Check the wordpress userid with wp_get_current_user() and do all magic you want :-) // as an example, let's change the value of a field if it is called 'testfield') $current_user = wp_get_current_user(); $jbn = $current_user->jbn_number; $telefoon = $current_user->phone; $geboortedatum = $current_user->birth; $gebdatum = date("d-m-Y", strtotime($geboortedatum)); if ($formfield['field_name']=='JBN Nummer') { return $jbn; } elseif ($formfield['field_name']=='Geboortedatum') { return $gebdatum; } elseif ($formfield['field_name']=='Test') { return $telefoon; } else { return $value; } } add_filter('eme_field_value_filter','my_formfield_filter',10,3); add_filter( 'wpmem_notify_addr', 'my_admin_email' ); function my_admin_email( $email ) { // single email example // $email = '[email protected]'; // multiple emails example // $email = '[email protected], [email protected]'; // take the default and append a second address to it example: $email = $email . ', [email protected]'; // return the result return $email; function my_eme_rsvp_payment_descr($description,$payment,$gateway_name) { $booking_ids = eme_get_payment_booking_ids($payment['id']); $booking = eme_get_booking($booking_ids[0]); $event = eme_get_event($booking['event_id']); $person = eme_get_person($booking['person_id']); $lastname = $person['lastname']; $firstname = $person['firstname']; $evenement = $event['event_name']; $description = "Betaling van $firstname $lastname voor $evenement"; return $description; } add_filter('eme_rsvp_paymentform_description_filter','my_eme_rsvp_payment_descr',10,3); } ?>
This is the code that works (after I placed the filter to the top;
<?php function my_eme_rsvp_payment_descr($description,$payment,$gateway_name) { $booking_ids = eme_get_payment_booking_ids($payment['id']); $booking = eme_get_booking($booking_ids[0]); $event = eme_get_event($booking['event_id']); $person = eme_get_person($booking['person_id']); $lastname = $person['lastname']; $firstname = $person['firstname']; $evenement = $event['event_name']; $description = "Betaling van $firstname $lastname voor $evenement"; return $description; } add_filter('eme_rsvp_paymentform_description_filter','my_eme_rsvp_payment_descr',10,3); add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } /** * Remove the href from empty links <code><a href="#"></code> in the nav menus * @param string $menu the current menu HTML * @return string the modified menu HTML */ function wpse_remove_empty_links( $menu ) { return str_replace( '<a href="#">', '<a>', $menu ); } add_filter( 'wp_nav_menu_items', 'wpse_remove_empty_links' ); add_filter('show_admin_bar', '__return_false'); /** * Change Default Display Name (Powered by yeahhub.com) */ function change_display_name( $user_id ) { $info = get_userdata( $user_id ); $args = array( 'ID' => $user_id, 'display_name' => $info->first_name . ' ' . $info->last_name ); wp_update_user( $args ); } add_action('user_register','change_display_name'); function my_formfield_filter($formfield,$postfield_name,$value) { // do a print_r of $formfield, etc ... to see the content. Check the wordpress userid with wp_get_current_user() and do all magic you want :-) // as an example, let's change the value of a field if it is called 'testfield') $current_user = wp_get_current_user(); $jbn = $current_user->jbn_number; $telefoon = $current_user->phone; $geboortedatum = $current_user->birth; $gebdatum = date("d-m-Y", strtotime($geboortedatum)); if ($formfield['field_name']=='JBN Nummer') { return $jbn; } elseif ($formfield['field_name']=='Geboortedatum') { return $gebdatum; } elseif ($formfield['field_name']=='Test') { return $telefoon; } else { return $value; } } add_filter('eme_field_value_filter','my_formfield_filter',10,3); add_filter( 'wpmem_notify_addr', 'my_admin_email' ); function my_admin_email( $email ) { // single email example // $email = '[email protected]'; // multiple emails example // $email = '[email protected], [email protected]'; // take the default and append a second address to it example: $email = $email . ', [email protected]'; // return the result return $email; } ?>
-
This reply was modified 6 years, 2 months ago by
pvwij.
The reason it didn’t work was because you placed function my_eme_rsvp_payment_descr (and the filter) inside your function my_admin_email (you missed the last ‘}’).
Copy it back to the bottom, but below the closing ‘}’ and it will all work as expected too. -
This reply was modified 6 years, 2 months ago by
- The topic ‘Payment description’ is closed to new replies.