SHARE
TWEET

Donation Text Box for PayPal

eventsmanager Aug 8th, 2019 (edited) 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. This snippet will allow you to add a donation text field to your Events Manager Pro booking form, which will then add that amount to the total payment when redirected to PayPal.
  4.  
  5. Instructions:
  6.  
  7. 1. in your Forms Editor, create a new field
  8. – label => Donation Amount
  9. – field id => donation_amount
  10. – type => select; then under option you can add the amount per line
  11.  
  12. 2. In your theme functions.php; paste the following snippet or for complete guide you can visit http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/
  13.  
  14. Reference: https://eventsmanagerpro.com/support/questions/donation-option-3/
  15.  
  16. */
  17.  
  18. function my_em_add_donation($paypal_vars, $EM_Booking, $EM_Gateway_Paypal){
  19.  $amount = $EM_Booking->booking_meta['booking']['donation_amount'];
  20.  if ( !empty($amount) ){
  21.   $itemcount = 1;
  22.   $itemcount = (count($EM_Booking->get_tickets_bookings()->tickets_bookings) + 1);
  23.   $paypal_vars['item_name_'.$itemcount] = wp_kses_data("Donation Amount");
  24.   $paypal_vars['quantity_'.$itemcount] = 1;
  25.   $paypal_vars['amount_'.$itemcount] = $amount;
  26.  }
  27.  return $paypal_vars;
  28. }
  29. add_filter('em_gateway_paypal_get_paypal_vars','my_em_add_donation',1,3);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top