Skip to content

Instantly share code, notes, and snippets.

@lorenzocaum
Created October 18, 2014 03:26
Show Gist options
  • Save lorenzocaum/e1d0bf671fd875f06593 to your computer and use it in GitHub Desktop.
Save lorenzocaum/e1d0bf671fd875f06593 to your computer and use it in GitHub Desktop.
dompdf workaround for the Event Espresso 3 ticketing add-on
<?php
global $org_options;
//Build the path to the css files
if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "tickets/templates/css/base.css")) {
$base_dir = EVENT_ESPRESSO_UPLOAD_URL . 'tickets/templates/css/';//If the template files have been moved to the uploads folder
} else {
$base_dir = ESPRESSO_TICKETING_FULL_URL.'templates/css/';//Default location
}
//Output the $data (array) variable that contains the attendee information and ticket settings
//echo "<pre>".print_r($data,true)."</pre>";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?php echo stripslashes_deep($org_options['organization']) ?> <?php _e('Ticket for', 'event_espresso'); ?> <?php echo stripslashes_deep($data->attendee->fname . ' ' .$data->attendee->lname) ?> | <?php echo $data->attendee->registration_id ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Base Stylesheet do not change or remove -->
<link rel="stylesheet" type="text/css" href="<?php echo $base_dir; ?>base.css" media="screen" />
<!-- Primary Style Sheet -->
<link rel="stylesheet" type="text/css" href="<?php echo $base_dir.$data->event->css_file; ?>" />
<!-- Make sure the buttons don't print -->
<style type="text/css">
@media print{
.noPrint{display:none!important;}
}
</style>
</head>
<body>
<div class="outside">
<div class="print_button_div">
<form>
<input class="print_button noPrint" type="button" value=" <?php _e( 'Print Ticket', 'event_espresso' ); ?> " onclick="window.print();return false;" />
</form>
<form method="post" action="javascript:(function()%7Bif(window%5B%27priFri%27%5D)%7Bwindow.print()%7Delse%7Bvar pfurl%3D%27%27%3Bpfstyle%3D%27nbk%27%3BpfBkVersion%3D%271%27%3Bif(window.location.href.match(/https/))%7Bpfurl%3D%27https://pf-cdn.printfriendly.com/ssl/main.js%27%7Delse%7Bpfurl%3D%27http://cdn.printfriendly.com/printfriendly.js%27%7D_pnicer_script%3Ddocument.createElement(%27SCRIPT%27)%3B_pnicer_script.type%3D%27text/javascript%27%3B_pnicer_script.src%3Dpfurl %2B %27%3Fx%3D%27%2B(Math.random())%3Bdocument.getElementsByTagName(%27head%27)%5B0%5D.appendChild(_pnicer_script)%3B%7D%7D)()%3B" >
<input class="print_button noPrint" type="submit" value=" <?php _e( 'Download PDF with Print Friendly', 'event_espresso' ); ?> " />
</form>
</div>
<div class="instructions"><?php _e('Print and bring this ticket with you to the event', 'event_espresso'); ?></div>
<div class="ticket">
<table width="100%" border="0">
<tr>
<td width="55%" rowspan="2" valign="top"><span class="top_event_title">[event_name]</span><br>
[start_date] [start_time] <br>
[ticket_type]<br>
[venue_title]<br>
<div class="logo">[ticket_logo_image]</div></td>
<td width="22%" align="right" valign="top"><div class="gravatar">[gravatar]</div></td>
<td width="23%" align="right" valign="top"><div class="qr_code">[qr_code]</div></td>
</tr>
<tr>
<td colspan="2" align="right" valign="top"><span class="price">[cost]</span><br>
[fname] [lname] (<?php _e('ID:', 'event_espresso'); ?> [att_id])<br>
[registration_id]<br>
<?php _e('Qty.', 'event_espresso'); ?> [ticket_qty]</td>
</tr>
</table>
</div>
<div class="extra_info">
<div class="divider"></div>
<table width="100%" border="0">
<tr>
<td width="45%" height="35" align="left" valign="top"><p><strong><?php _e('Location:', 'event_espresso'); ?></strong><br>
[venue_title]<br>
[venue_address]<br>
[venue_address2]<br>
[venue_city], [venue_state]<br>
[venue_phone]</p>
<p><strong><?php _e('More Information:', 'event_espresso'); ?></strong></p>
<p>[venue_description]</p>
<p><strong><?php _e('Ticket Instructions:', 'event_espresso'); ?></strong></p>
<p>[ticket_content]</p></td>
<td width="55%" valign="top">[google_map_image]</td>
</tr>
</table>
</div>
<div class="footer"><?php echo sprintf( __( 'Powered by the <a href="%s" target="_blank">Event Espresso Ticketing System</a> for WordPress', 'event_espresso' ) , 'http://eventespresso.com' ); ?></div>
</div>
</body>
</html>
@lorenzocaum
Copy link
Author

dompdf has an issue with non-English languages where certain characters may appear as question marks. This workaround substitutes in the Print Friendly service which features a PDF option.

Here are the steps for applying this workaround:

  1. Take a look at the following tutorial: http://eventespresso.com/wiki/how-to-create-a-custom-ticket/#customticket

  2. Login to your WordPress site with your preferred SFTP or FTP client. FileZilla and Cyberduck are free options.

  3. Browse to the following location:

wp-content/plugins/espresso-ticketing

  1. Download the templates folder to your computer

  2. Browse to the following location:

wp-content/uploads/espresso/tickets

  1. Upload the templates folder to the location above.

  2. Download a copy of the index.php file at the top of this page to your computer and unzip it:

https://gist.github.com/lorenzocaum/e1d0bf671fd875f06593/download

  1. Upload the index.php file that you just downloaded (and unzipped) from your computer to the following location:

wp-content/uploads/espresso/tickets/templates

You'll be prompted to overwrite the existing index.php file. Go ahead and do that. Then complete a test registration and load the ticket in your web browser.

You should now see a Download PDF with Print Friendly button. Click on this button and a window will appear with the ticket information. Click on the PDF icon and your ticket will download as a PDF file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment