-
-
Save Pebblo/09fa5079036ecc369b6a to your computer and use it in GitHub Desktop.
This method can be added to the Espresso_PDF class in gateways/invoice/function.pdf.php to prepare some data to display the prices without the surcharge, and the surcharge amount as line items. Works with the Event Espresso 3.1.35.P or greater invoice template. Please see https://gist.github.com/joshfeck/e2b91cd6599000ecb772 for example template…
This file contains 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
<?php | |
//Please do not include the opening php tags above | |
function my_itemised_surcharge($registration_ids, $attendees){ | |
$options = get_option('events_organization_settings'); | |
$currency = $options['currency_symbol']; | |
$this->SetFillColor(192,192,192); | |
// pull the selected ticket price breakdown from the database | |
global $wpdb, $org_options; | |
foreach( $registration_ids as $registration_id ) { | |
$price_query = "SELECT event_id, price_option FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id=%s"; | |
$att_price_info = $wpdb->get_results( $wpdb->prepare($price_query, $registration_id )); | |
//var_dump($att_price_info); | |
foreach ( $att_price_info as $price_item ) { | |
$event_id = $price_item->event_id; | |
$price_option = $price_item->price_option; | |
} | |
$SQL = "SELECT * FROM " . EVENTS_PRICES_TABLE . " WHERE event_id=%d AND %s IN (price_type, member_price_type)"; | |
$event_prices = $wpdb->get_row($wpdb->prepare($SQL, $event_id, $price_option), ARRAY_A); | |
extract($event_prices); | |
if($price_option == $member_price_type) { | |
$single_cost = $member_price; | |
} else { | |
$single_cost = $event_cost; | |
} | |
} | |
$surcharge_amt = $attendees[0][0][2] - $single_cost; | |
// print unit price w/o surcharge | |
$this->Cell(95, 10, __('Price per unit excluding Surcharge/tax/VAT/GST:','event_espresso'), 0, 0, 'L', true); | |
$this->Cell(90, 10, html_entity_decode($currency, ENT_QUOTES, 'ISO-8859-15') . number_format($single_cost,2, '.', ''), 0, 1, 'C', true); | |
// print unit surcharge | |
$this->Cell(95, 10, __('Surcharge/tax/VAT/GST per unit:','event_espresso'), 0, 0, 'L', true); | |
$this->Cell(90, 10, html_entity_decode($currency, ENT_QUOTES, 'ISO-8859-15') . number_format($surcharge_amt,2, '.', ''), 0, 1, 'C', true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment