I am trying to use a Wordpress module called WooCommerce PDF Invoices to make event tickets by modifying the layout of the invoice to create an online ticket to printout. I’ve successful reformatted the layout and it works like a charm except for one thing.
The problem I have is that no matter what is bought the invoice reads “This is a ticket” which I hardcoded into the invoice design. What I would like is an if/then statement inserted into the invoice design that will print between “This is a ticket” or “This is a receipt” depending on if they purchase one of the 4 ticket items.
"This is a recept" If ticket 1 then print "This is a ticket" else print "This is a receipt. If ticket 2 then print "This is a ticket" else print "This is a receipt. If ticket 3 then print "This is a ticket" else print "This is a receipt. If ticket 4 then print "This is a ticket" all else print "This is a receipt."
I completely redesigned the woocommerce pdf invoice to look like an online ticket. The first half looks like an actual ticket.
[php]<?php global $wpo_wcpdf; ?>
<?php
if( $wpo_wcpdf->get_header_logo_id() ) {
$wpo_wcpdf->header_logo();
} else {
_e( 'Ticket', 'wpo_wcpdf' );
}
?>
<?php $date_setting = isset($wpo_wcpdf->settings->template_settings['display_date'])?$wpo_wcpdf->settings->template_settings['display_date']:'order_date'; $number_setting = isset($wpo_wcpdf->settings->template_settings['display_number'])?$wpo_wcpdf->settings->template_settings['display_number']:'order_number'; // set $display date & label to user setting // set $display number & label to user setting |
<?php $wpo_wcpdf->shop_name(); ?>SPONSORED BY: SPONSOR 1 LOGO | SPONSOR 2 LOGO |
|
||
<?php $wpo_wcpdf->shop_address(); ?>
|
||||
***This is a Receipt*** |
<?php _e('Shop Items', 'wpo_wcpdf'); ?> | <?php _e('Quantity', 'wpo_wcpdf'); ?> | <?php _e('Price', 'wpo_wcpdf'); ?> | |
---|---|---|---|
<?php $description_label = __( 'Description', 'wpo_wcpdf' ); // registering alternate label translation ?>
<?php echo $item['name']; ?><?php echo $item['meta']; ?>
|
<?php echo $item['quantity']; ?> | <?php echo $item['order_price']; ?> | |
|
<?php if ( $wpo_wcpdf->get_shipping_notes() ) : ?>
<?php _e( 'Customer Notes', 'wpo_wcpdf' ); ?><?php $wpo_wcpdf->shipping_notes(); ?> <?php endif; ?> |
I want to identify one of my 4 ticket items that may appear where the invoice prints the items and when one of them does appear it changes “This is a receipt” to “This is a ticket” in the first half. Is something like this possible? If so, can anyone give me a direction to find the coding for this? Can anybody give me an idea how to write this in php. I’m a pro at html but I’ve only taught myself how to modify existing php coding. I can’t write it from scratch. Any help is appreciated.