Ticket Template Code Examples

Party Small Ticket

We separated the PDF and Screen template parts. The first part is for the ticket. The second part (else-statement) contains the default template.

No padding: checked

Width: 210

Height: 90

QR code size: 50

				
					{% apply spaceless %}{% autoescape false %}
{%- if forPDFOutput -%}
    <table style="width:100%;padding:0;margin:0">
        <tr>
            <td style="width:33%;"><img class="lazy" decoding="async" width="70mm" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2070%2070'%3E%3C/svg%3E" data-src="{{ getMediaData(PRODUCT.get_image_id).url }}"></td>
            <td style="width:34%;font-size:10pt;">
                <div style="color:black;text-align:center;font-size:14pt;font-weight:bold;">{{ PRODUCT.get_name|escape }}</div>
                
                {%- if not OPTIONS.wcTicketHideDateOnPDF and TICKET.start_date is not empty -%}
                <table style="font-size:9p;"><tr>
                    <td style="border-top:1px solid black;border-bottom:1px solid black;">{{ TICKET.start_date_timestamp|date("l")|upper }}</td>
                    <td style="border-top:1px solid black;border-bottom:1px solid black;text-align:center;color:#d83565;"><b>{{ TICKET.start_date_timestamp|date("M jS")|upper }}</b></td>
                    <td style="border-top:1px solid black;border-bottom:1px solid black;text-align:right;">{{ TICKET.start_date_timestamp|date("Y")|upper }}</td>
                </tr></table>
                {%- endif -%}
                
                {%- if OPTIONS.wcTicketDisplayShortDesc -%}
                    <div>
                    {%- if OPTIONS.wcTicketPDFStripHTML == 3 -%}
                        {{- TICKET.short_desc|escape -}}
                    {% endif %}
                    {%- if OPTIONS.wcTicketPDFStripHTML == 2 -%}
                        {{- TICKET.short_desc|escape('wp_filter_nohtml_kses') -}}
                    {%- else -%}
                        {{- TICKET.short_desc|escape('wp_kses_post')|raw|nl2br -}}
                    {% endif %}
                    </div>
                {% endif %}
                
                {%- if not OPTIONS.wcTicketDontDisplayPrice -%}
                    <div style="text-align:center;">
                    <br><b>{{ wc_price(ORDER_ITEM.get_subtotal + ORDER_ITEM.get_subtotal_tax) }}</b>
                    </div>
                {% endif %}

                {%- if TICKET.location is not empty -%}
                    <div style="text-align:center;font-size:9pt;border-top:1px solid black;">{{ TICKET.location|escape('wp_kses_post') }}</div>
                {%- endif -%}
            
                <div style="text-align:center;font-size:8pt;">{{ TICKET.public_ticket_number }}</div>
            </td>
            <td style="width:33%;text-align:center;">
                <br>
                {%- if TICKET.info is not empty -%}
                    <p>
                    {%- if OPTIONS.wcTicketPDFStripHTML == 3 -%}
                        {{- TICKET.info|escape -}}
                    {% endif %}
                    {%- if OPTIONS.wcTicketPDFStripHTML == 2 -%}
                        {{- TICKET.info|escape('wp_filter_nohtml_kses') -}}
                    {%- else -%}
                        {{- TICKET.info|escape('wp_kses_post')|raw|nl2br -}}
                    {%- endif -%}
                    </p>
                {%- endif -%}
                {QRCODE_INLINE}
            </td>
        </tr>
    </table>
{% else %}
    <!-- screen -->
    <h3 style="color:black;text-align:center;">{{ OPTIONS.wcTicketHeading|escape('wp_kses_post')|raw }}</h3>
    <h4 style="color:black;">{{ PRODUCT.get_name|escape }}</h4>

    <table style="width:100%;padding:0;margin:0;" class="ticket_content_upper">
        <tr valign="top">
            <td style="padding:0;margin:0;background-color:white;border:0;">
                {%- if OPTIONS.wcTicketPDFDisplayVariantName and PRODUCT.get_attributes|length > 0 -%}
                    <p>
                    {%- for item in PRODUCT.get_attributes -%}
                        {{- item|striptags -}}
                    {%- endfor -%}
                    </p>
                {%- endif -%}

                {%- if not OPTIONS.wcTicketHideDateOnPDF and TICKET.start_date is not empty -%}
                    <p>{{- TICKET.date_as_string -}}
                    {%- if TICKET.end_date is not empty and date(TICKET.end_date_timestamp) < date() -%}
                        <span style="color:red;"> {{ OPTIONS.wcTicketTransExpired }}</span>
                    {%- endif -%}
                    {%- if TICKET.location is not empty -%}
                        <br>{{ OPTIONS.wcTicketTransLocation }} <b>{{ TICKET.location|escape('wp_kses_post') }}</b>
                    {%- endif -%}
                    </p>
                {%- else -%}
                    {%- if TICKET.location is not empty -%}
                        <p>{{ OPTIONS.wcTicketTransLocation }} <b>{{ TICKET.location|escape('wp_kses_post') }}</b></p>
                    {%- endif -%}
                {%- endif -%}

                {%- if OPTIONS.wcTicketDisplayShortDesc -%}
                    <p>
                    {%- if OPTIONS.wcTicketPDFStripHTML == 3 -%}
                        {{- TICKET.short_desc|escape -}}
                    {% endif %}
                    {%- if OPTIONS.wcTicketPDFStripHTML == 2 -%}
                        {{- TICKET.short_desc|escape('wp_filter_nohtml_kses') -}}
                    {%- else -%}
                        {{- TICKET.short_desc|escape('wp_kses_post') -}}
                    {% endif %}
                    </p>
                {% endif %}

                {%- if TICKET.info is not empty -%}
                    <p>
                    {%- if OPTIONS.wcTicketPDFStripHTML == 3 -%}
                        {{- TICKET.info|escape -}}
                    {% endif %}
                    {%- if OPTIONS.wcTicketPDFStripHTML == 2 -%}
                        {{- TICKET.info|escape('wp_filter_nohtml_kses') -}}
                    {%- else -%}
                        {{- TICKET.info|escape('wp_kses_post') -}}
                    {%- endif -%}
                    </p>
                {%- endif -%}
            </td>
        </tr>
    </table>

    <table style="width:100%;padding:0;margin:0;">
        <tr valign="top">
            <td style="color:black;width:50%;padding:0;padding-right:5px;margin:0;background-color:white;border:0;">
                {%- if not OPTIONS.wcTicketDontDisplayCustomer -%}
                    <p><b>{{ OPTIONS.wcTicketTransCustomer|escape('wp_kses_post') }}</b>
                    <br>{{ ORDER.get_formatted_billing_address|trim|escape('wp_kses_post') }}
                    </p>
                {% endif %}
            </td>
            <td style="color:black;width:50%;padding:0;margin:0;background-color:white;border:0;">
                {%- if not OPTIONS.wcTicketDontDisplayPayment -%}
                    <p><b>{{ OPTIONS.wcTicketTransPaymentDetail|escape('wp_kses_post') }}</b>
                    <br>{{ OPTIONS.wcTicketTransPaymentDetailPaidAt|escape('wp_kses_post') }} <b>{{ TICKET.order_date_paid_text|escape }}</b>
                    <br>{{ OPTIONS.wcTicketTransPaymentDetailCompletedAt|escape('wp_kses_post') }} <b>{{ TICKET.order_date_completed_text|escape }}</b>
                    {%- if ORDER.get_payment_method_title is empty %}
                        <br>{{ OPTIONS.wcTicketTransPaymentDetailFreeTicket|escape('wp_kses_post') }}
                    {% else %}
                        <br>{{ OPTIONS.wcTicketTransPaymentDetailPaidVia|escape('wp_kses_post') }} <b>{{ ORDER.get_payment_method_title|escape }} (#{{ ORDER.get_transaction_id|escape }})</b>
                    {% endif %}
                    {%- if ORDER.get_coupon_codes -%}
                        <br>{{ OPTIONS.wcTicketTransPaymentDetailCouponUsed|escape('wp_kses_post') }} <b>{{ ORDER.get_coupon_codes|join(", ") }}</b><br>
                    {% endif %}
                    </p>
                {% endif %}
            </td>
        </tr>
    </table>

    {%- if METAOBJ.user.value is not empty and OPTIONS.wcTicketDisplayTicketUserValue -%}
        <p>{{ OPTIONS.wcTicketTransDisplayTicketUserValue|escape('wp_kses_post') }} {{ METAOBJ.user.value|escape }}</p>
    {%- endif -%}

    {%- if METAOBJ.wc_ticket.name_per_ticket is not empty -%}
        <p>{{ TICKET.name_per_ticket_label ~ " " ~ METAOBJ.wc_ticket.name_per_ticket }}</p>
    {%- endif -%}

    {%- if METAOBJ.wc_ticket.value_per_ticket is not empty -%}
        <p>{{ TICKET.value_per_ticket_label ~ " " ~ METAOBJ.wc_ticket.value_per_ticket }}</p>
    {%- endif -%}

    {%- if OPTIONS.wcTicketDisplayPurchasedItemFromOrderOnTicket and ORDER.get_items|length > 1 %}
        <br><b>Additional order items</b>
        {% for item_id, item in ORDER.get_items %}
            {%- if item_id != METAOBJ.woocommerce.item_id -%}
                <br>{{ item.get_quantity }}x {{ item.get_name|escape }}
            {%- endif -%}
        {% endfor %}
    {%- endif -%}

    {%- if OPTIONS.wcTicketDisplayCustomerNote and ORDER.get_customer_note is not empty -%}
        <p><i>"{{ ORDER.get_customer_note|escape }}"</i></p>
    {% endif %}

    {%- if OPTIONS.wcTicketDisplayPurchasedTicketQuantity -%}
        {% if forPDFOutput %}<br>{% endif %}
        <br>{{ OPTIONS.wcTicketPrefixTextTicketQuantity|escape('wp_kses_post')|replace({'{TICKET_POSITION}': TICKET.order_item_pos, '{TICKET_TOTAL_AMOUNT}': TICKET.codes|length}) }}
    {% endif %}

    {%- if TICKET.text_redeem_amount is not empty -%}
        <br>{{ TICKET.text_redeem_amount }}
    {% endif %}

    <br><br>
    <table style="width:100%;padding:0;margin:0;">
        <tr valign="top">
            <td style="color:black;width:50%;padding:0;padding-right:5px;margin:0;background-color:white;border:0;">{{ OPTIONS.wcTicketTransTicket|escape('wp_kses_post') }} <b>{{ CODEOBJ.code_display }}</b>
                {%- if not OPTIONS.wcTicketDontDisplayPrice -%}
                    <br>{{ OPTIONS.wcTicketTransPrice|escape('wp_kses_post') }}
                    <b>{{ wc_price(ORDER_ITEM.get_subtotal + ORDER_ITEM.get_subtotal_tax) }}</b>
                    {% if PRODUCT.get_price != ORDER_ITEM.get_subtotal %}
                    <br>{{ OPTIONS.wcTicketTransProductPrice|escape('wp_kses_post') }} {{ wc_price(PRODUCT.get_price) }}
                    {% endif %}
                {% endif %}
            </td>
            <td style="color:black;width:50%;padding:0;margin:0;background-color:white;border:0;">
                {%- if OPTIONS.wcTicketDisplayTicketListName -%}
                    {{ LISTOBJ.name|escape('wp_kses_post')|raw|nl2br }}
                {% endif %}
                {%- if OPTIONS.wcTicketDisplayTicketListDesc -%}
                    {%- if OPTIONS.wcTicketDisplayTicketListName -%}<br>{% endif %}{{ LIST_METAOBJ.desc|escape('wp_kses_post')|raw|nl2br }}<br>
                {% endif %}
            </td>
        </tr>
    </table>

    {%- if not isScanner -%}
        <div id="qrcode" style="background-color:white !important;padding:15px;margin-top:3em;text-align:center;"></div>
        <script>jQuery("#qrcode").qrcode("{{ TICKET.qrCodeContent|escape('html_attr')|raw }}");</script>
    {% endif %}
    <p style="text-align:center;">{{ TICKET.public_ticket_number }}</p>
    
{%- endif -%}
{% endautoescape %}{% endapply %}
				
			
de_DEDeutsch

Login