Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- 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, Stripe or Offline Payment Gateways.
- Instructions:
- 1. in your Forms Editor, create a new field
- – label => Donation Amount
- – field id => donation_amount
- – type => select; then under option you can add the amount per line
- 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/
- Reference: https://eventsmanagerpro.com/support/questions/donation-option-3/
- */
- function my_em_price_adjustments( $EM_Event, $EM_Booking, $post_validation ){
- if( $post_validation ){
- if( empty($EM_Booking->booking_meta['surcharges']) ) $EM_Booking->booking_meta['surcharges'] = array();
- //donation_amount = Field Id from Events > Forms Editor
- $amount = ( !empty($EM_Booking->booking_meta['booking']['donation_amount']) ) ? $EM_Booking->booking_meta['booking']['donation_amount']:1;
- $label = "Test Surcharge";
- $EM_Booking->booking_meta['surcharges'][] = array(
- 'name' => $label,
- //'desc' => 'Some type of surcharge description',
- 'type' => '#', //numerical discount i.e. $10.00 off
- 'amount' => $amount,
- 'tax' => 'pre' //discount applied BEFORE taxes have been added, and IS taxable
- );
- }//END - if( $post_validation ){
- }
- add_action('em_booking_add', 'my_em_price_adjustments', 10, 3);
Add Comment
Please, Sign In to add comment