Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // create #_PAYMENTINFO (in email)
- function em_paymentinfo_placeholder($replace, $EM_Event, $result) {
- if ( $result == '#_PAYMENTINFO' ) {
- global $EM_Event;
- global $EM_Booking;
- $home_url = home_url();
- $stylesheeturl = get_stylesheet_directory_uri();
- $eventid = $EM_Event->event_id;
- $event_post_id = $EM_Event->output("#_EVENTPOSTID");
- $ibaninfo = get_post_meta($event_post_id, 'Bank IBAN', true);
- $bicinfo = get_post_meta($event_post_id, 'Bank BIC', true);
- $accountholder = get_post_meta($event_post_id, 'Account holder', true);
- $paypaladdress = get_post_meta($event_post_id, 'Paypal', true);
- $paypalcurrency = get_post_meta($event_post_id, 'Paypal currency', true);
- if ($paypalcurrency) {
- if ( $paypalcurrency == 'USD' ) {
- $paypalcurrency = '$';
- } elseif ( $paypalcurrency == 'EUR' ) {
- $paypalcurrency = '€';
- } else {
- $paypalcurrency = $paypalcurrency;
- }
- } else {
- $paypalcurrency = '€';
- }
- $merchantid = get_post_meta($event_post_id, 'Merchant ID', true);
- // $stripzerodprice = $EM_Booking->booking_price;
- // $stripzerodprice = substr($EM_Booking->booking_price, 0, -2);
- $stripzerodprice = str_replace("0000","00",$EM_Booking->booking_price);
- $stripzerodprice = str_replace(".",",",$stripzerodprice);
- $replace = '';
- $replace .= '<p><b>PAYMENT INFO</b></p>';
- $replace .= '<p>Total registration price: '.$paypalcurrency.' '.$stripzerodprice.'.</p>';
- $paycounter = 0;
- if ( $ibaninfo && $bicinfo ) { $paycounter++; }
- if ( $paypaladdress || $merchantid ) { $paycounter++; }
- if ( $paycounter > 1 ) {
- $replace .= '<p>You have '.$paycounter.' payment options.</p>';
- }
- if ( $ibaninfo ) {
- $replace .= '<p><b>PAY BY BANK</b><br />';
- $replace .= 'IBAN: '.$ibaninfo.'<br />';
- $replace .= 'BIC/Swift: '.$bicinfo.'<br />';
- $replace .= 'Account holder: '.$accountholder.'</p>';
- }
- if ( $merchantid || $paypaladdress ) {
- $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>';
- }
- $replace .= '<p><strong>IMPORTANT</strong><br />Use this payment description for bank (and Paypal, if asked).</p>';
- $replace .= '<p class="paymentinfo">'.$EM_Booking->output("#_EVENTNAME").' - '.$EM_Booking->output("#_BOOKINGID").' - '.$EM_Booking->output("#_BOOKINGNAME").'</p>';
- if ( !$ibaninfo && !$paypaladdress && !$merchantid ) {
- $cashevents = array('');
- if (in_array($event_post_id, $cashevents)) {
- $replace .= "<p>This event has on-site cash payments only.</p>";
- } else {
- $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>";
- }
- }
- }
- return $replace;
- }
- add_filter('em_event_output_placeholder','em_paymentinfo_placeholder', 1, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement