Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created September 10, 2024 18:52
Show Gist options
  • Save andrasguseo/e85bfc36030cea6a991d3885833031f7 to your computer and use it in GitHub Desktop.
Save andrasguseo/e85bfc36030cea6a991d3885833031f7 to your computer and use it in GitHub Desktop.
ETP > Template overrides for the PDF file generation
These are template overrides to adjust how the generated PDF files look like.
1. Changes the column widths for the additional fields which are arranged in 2 columns.
The split is 66% and 34%.
2. Changes the font size for all the additional fields to 4pt.
The latter can be further fine-tuned by checking which additional field is being processed
if you want to make only certain texts smaller.
<?php
/**
* PDF Pass: Body - Ticket Info - Attendee Fields
*
* Place this template in your own theme by creating a file at:
* wp-content/themes/[your-theme]/tribe/tickets-plus/integrations/event-tickets-wallet-plus/pdf/pass/body/ticket-info/attendee-fields.php
*
* See more documentation about our views templating system.
*
* @link https://evnt.is/event-tickets-wallet-plus-tpl Help article for Wallet Plus template files.
*
* @since 5.8.0
*
* @version 5.8.0
*/
if ( empty( $attendee['attendee_meta'] ) ) {
return;
}
?>
<tr>
<td class="tec-tickets__wallet-plus-pdf-attendee-details-wrapper">
<table class="tec-tickets__wallet-plus-pdf-attendee-fields-table">
<?php
$count = 0;
foreach ( $attendee['attendee_meta'] as $key => $value ) {
if ( $count % 2 == 0 ) {
echo '<tr>';
}
?>
<?php
// Set first column to 20%, second column to 80%
if ( $count % 2 === 1 || $count === count( $attendee['attendee_meta'] ) - 1 ) {
echo '<td width="34%">';
} else {
echo '<td width="66%">';
}
?>
<?php $this->template( 'pass/body/ticket-info/attendee-fields/field', [ 'key' => $key, 'value' => $value ] ); ?>
</td>
<?php
// Close the row for every second item or at the end of the array.
if ( $count % 2 === 1 || $count === count( $attendee['attendee_meta'] ) - 1 ) {
echo '</tr>';
}
$count++;
}
?>
</table>
</td>
</tr>
<?php
/**
* PDF Pass: Body - Ticket Info - Attendee Field Value
*
* Place this template in your own theme by creating a file at:
* wp-content/themes/[your-theme]/tribe/tickets-plus/integrations/event-tickets-wallet-plus/pdf/pass/body/ticket-info/attendee-fields/value.php
*
* See more documentation about our views templating system.
*
* @link https://evnt.is/event-tickets-wallet-plus-tpl Help article for Wallet Plus template files.
*
* @since 5.8.0
*
* @version 5.8.0
*/
if ( empty( $value ) ) {
return;
}
?>
<tr>
<td class="tec-tickets__wallet-plus-pdf-attendee-fields-field-value" style="font-size: 4pt !important;">
<?php echo esc_html( $value ); ?>
</td>
</tr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment