Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- This snippet adds an placeholder called #_BOOKINGPAYPALLINK which displays a link to PayPal for payment of a booking.
- This is a standard WordPress hook function. For installation instructions of custom snippets see here - http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/
- */
- add_filter('em_booking_output_placeholder','my_em_get_payment_type',1,3);
- function my_em_get_payment_type($replacement, $EM_Booking, $result){
- if (is_object($EM_Booking)) {
- if ($result == '#_BOOKINGPAYPALLINK') {
- $count = 1;
- $url_params = "https://www.paypal.com/cgi-bin/webscr?cmd=_cart&upload=1";
- $url_params .= "&business=".get_option('em_paypal_email');
- $url_params .= "&custom=".$EM_Booking->booking_id.':'.$EM_Booking->event_id;
- $url_params .= "¤cy_code=".get_option('dbem_bookings_currency', 'USD');
- //For discount
- $discount = $EM_Booking->get_price_discounts_amount('pre') + $EM_Booking->get_price_discounts_amount('post');
- $url_params .= "&discount_amount_cart=".$discount;
- foreach( $EM_Booking->get_tickets_bookings()->tickets_bookings as $EM_Ticket_Booking ){
- $price = $EM_Ticket_Booking->get_price() / $EM_Ticket_Booking->get_spaces();
- if( $price > 0 ){
- $url_params .= "&item_name_".$count."=".wp_kses_data($EM_Ticket_Booking->get_ticket()->name);
- $url_params .= "&quantity_".$count."=".$EM_Ticket_Booking->get_spaces();
- $url_params .= "&amount_".$count."=".round($price,2);
- }
- $count++;
- }
- $replacement = "<a href='".$url_params."'>"."Pay Here"."</a>";
- }
- }
- return $replacement;
- }
Add Comment
Please, Sign In to add comment