Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created June 3, 2014 16:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/52ac749150322a2e4221 to your computer and use it in GitHub Desktop.
Save joshfeck/52ac749150322a2e4221 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…
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 ));
foreach ( $att_price_info as $price_item ) {
$event_id = $price_item->event_id;
$price_option = $price_item->price_option;
}
$SQL = "SELECT event_cost FROM " . EVENTS_PRICES_TABLE . " WHERE event_id=%d AND price_type=%s ORDER BY id ASC LIMIT 1";
$single_cost = $wpdb->get_var( $wpdb->prepare( $SQL, $event_id, $price_option ));
}
$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