Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created April 26, 2024 09:31
Show Gist options
  • Save andrasguseo/83d1509f96b70160b1dfc95bfc5a97eb to your computer and use it in GitHub Desktop.
Save andrasguseo/83d1509f96b70160b1dfc95bfc5a97eb to your computer and use it in GitHub Desktop.
ET+ > Exclude QR code from selected tickets
<?php
/**
* Description: Exclude QR codes from selected tickets.
* Usage: Paste the below snippet into your active (child) theme's functions.php file
* or use a plugin like Code Snippets.
*
* Plugin: Event Tickets, Event Tickets Plus
* Author: Andras Guseo
* Last updated: 2024-03-25
*/
/**
* Allow filtering the ticket IDs that should not get the QR code.
* Needs a template override for qr-image.php
* @return int[]
*/
function tec_my_tickets_without_qr(): array {
// List the post IDs of the tickets for which you don't want to send a QR code.
return [
977,
983,
];
}
add_filter( 'tec_labs_et_tickets_without_qr', 'tec_my_tickets_without_qr' );
<?php
/**
* Event Tickets Emails: Main template > Body > Ticket > QR Image.
*
* This is a template override for the following file:
* event-tickets-plus/src/views/emails/template-parts/body/ticket/qr-image.php
*
* Place this file here:
* wp-content/themes/[your-theme]/tribe/tickets-plus/emails/template-parts/body/ticket/qr-image.php
*
* See more documentation about our views templating system.
*
* @link https://evnt.is/tickets-emails-tpl Help article for Tickets Emails template files.
*
* @since 5.6.10
*
* @version 5.6.10
*
* @var string $qr URL of QR image.
* @var boolean $include_qr Whether or not QR codes are set to be shown.
* @var array $ticket The ticket details.
*/
// If QR codes not included or URL is empty, bail.
if ( ! $include_qr || empty( $qr ) ) {
return;
}
// Get the ticket IDs, which should NOT have a QR code.
$tickets_without_qr = apply_filters( 'tec_labs_et_tickets_without_qr', [] );
// Bail, if the current ticket ID is on the exclusion list.
if (
is_array( $tickets_without_qr )
&& in_array( $ticket['product_id'], $tickets_without_qr )
) {
return;
}
?>
<td class="tec-tickets__email-table-content-qr-container" rowspan="2">
<img
src="<?php echo esc_attr( $qr ); ?>"
class="tec-tickets__email-table-content-qr-image"
/>
</td>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment