Advertisement
Beee

#_PAYMENTINFO

Aug 10th, 2016
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.46 KB | None | 0 0
  1. // create #_PAYMENTINFO (in email)
  2. function em_paymentinfo_placeholder($replace, $EM_Event, $result) {
  3.     if ( $result == '#_PAYMENTINFO' ) {
  4.         global $EM_Event;
  5.         global $EM_Booking;
  6.         $home_url           = home_url();
  7.         $stylesheeturl      = get_stylesheet_directory_uri();
  8.         $eventid            = $EM_Event->event_id;
  9.         $event_post_id      = $EM_Event->output("#_EVENTPOSTID");
  10.         $ibaninfo           = get_post_meta($event_post_id, 'Bank IBAN', true);
  11.         $bicinfo            = get_post_meta($event_post_id, 'Bank BIC', true);
  12.         $accountholder      = get_post_meta($event_post_id, 'Account holder', true);
  13.         $paypaladdress      = get_post_meta($event_post_id, 'Paypal', true);
  14.         $paypalcurrency     = get_post_meta($event_post_id, 'Paypal currency', true);
  15.  
  16.         if ($paypalcurrency) {
  17.             if ( $paypalcurrency == 'USD' ) {
  18.                 $paypalcurrency = '$';
  19.             } elseif ( $paypalcurrency == 'EUR' ) {
  20.                 $paypalcurrency = '€';
  21.             } else {
  22.                 $paypalcurrency = $paypalcurrency;
  23.             }
  24.         } else {
  25.             $paypalcurrency = '€';
  26.         }
  27.  
  28.         $merchantid         = get_post_meta($event_post_id, 'Merchant ID', true);
  29.         // $stripzerodprice    = $EM_Booking->booking_price;
  30.         // $stripzerodprice     = substr($EM_Booking->booking_price, 0, -2);
  31.         $stripzerodprice    = str_replace("0000","00",$EM_Booking->booking_price);
  32.         $stripzerodprice    = str_replace(".",",",$stripzerodprice);
  33.         $replace            = '';
  34.         $replace            .= '<p><b>PAYMENT INFO</b></p>';
  35.         $replace            .= '<p>Total registration price: '.$paypalcurrency.' '.$stripzerodprice.'.</p>';
  36.  
  37.         $paycounter = 0;
  38.         if ( $ibaninfo && $bicinfo ) { $paycounter++; }
  39.         if ( $paypaladdress || $merchantid ) { $paycounter++; }
  40.         if ( $paycounter > 1 ) {
  41.             $replace .= '<p>You have '.$paycounter.' payment options.</p>';
  42.         }
  43.  
  44.         if ( $ibaninfo ) {
  45.             $replace .= '<p><b>PAY BY BANK</b><br />';
  46.             $replace .= 'IBAN: '.$ibaninfo.'<br />';
  47.             $replace .= 'BIC/Swift: '.$bicinfo.'<br />';
  48.             $replace .= 'Account holder: '.$accountholder.'</p>';
  49.         }
  50.         if ( $merchantid || $paypaladdress ) {
  51.             $replace .= '<p><b>PAY BY PAYPAL</b><br /><a href="'.$home_url.'/profile/my-registrations/"><img src="'.$stylesheeturl.'/assets/images/pay-now-paypal.jpg" class="paypalbutton" alt="Pay now with paypal" /></a></p>';
  52.         }
  53.         $replace .= '<p><strong>IMPORTANT</strong><br />Use this payment description for bank (and Paypal, if asked).</p>';
  54.         $replace .= '<p class="paymentinfo">'.$EM_Booking->output("#_EVENTNAME").' - '.$EM_Booking->output("#_BOOKINGID").' - '.$EM_Booking->output("#_BOOKINGNAME").'</p>';
  55.  
  56.         if ( !$ibaninfo && !$paypaladdress && !$merchantid ) {
  57.             $cashevents = array('');
  58.             if (in_array($event_post_id, $cashevents)) {
  59.                 $replace .= "<p>This event has on-site cash payments only.</p>";
  60.             } else {
  61.                 $replace .= "<p>The organizer hasn't entered his payment details yet (their fault, sorry), so we can't provide them right now. Once he enters them, we will send you the email.</p>";
  62.             }
  63.         }
  64.     }
  65.     return $replace;
  66. }
  67. add_filter('em_event_output_placeholder','em_paymentinfo_placeholder', 1, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement