Created
November 6, 2014 19:42
-
-
Save sidharrell/c248f6905d3d139967c3 to your computer and use it in GitHub Desktop.
Volume Discount for EE3 with No Info Required on Additional Attendees
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('action_hook_espresso_save_attendee_data', 'apply_volume_discount_hook_function'); | |
| function apply_volume_discount_hook_function ( $attendee_data ) { | |
| if ( !empty($attendee_data['event_meta']['VD_threshold']) && | |
| !empty($attendee_data['event_meta']['VD_discount']) && | |
| (int)$attendee_data['quantity'] >= (int)$attendee_data['event_meta']['VD_threshold'] ) { | |
| global $wpdb; | |
| $data = array( | |
| 'final_price' => max(array( 0, (float)$attendee_data['final_price'] - (float)$attendee_data['event_meta']['VD_discount'] )) | |
| ); | |
| $where = array( | |
| 'id' => absint( $attendee_data['attendee_id'] ) | |
| ); | |
| $format = array( | |
| '%f' | |
| ); | |
| $where_format = array( | |
| '%d' | |
| ); | |
| $wpdb->update( EVENTS_ATTENDEE_TABLE, $data, $where, $format, $where_format ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment