• Resolved Erling

    (@erling)


    It works fine – people get their ticket in their email etc. But I wonder if it would be possible to get the ordering person’s name on the ticket. Right now it’s only an order number, and it would be nice to style the ticket at bit more.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi @erling,

    You can try to add the following hooks on the next file:

    yith-event-tickets-for-woocommerce\templates\tickets\default-html.php

    
    <div id="content_title">
    <h2><?php
         if('on' == $display_ticket_number){
                 echo '#' . $post->ID . ' ';
         }
          echo $post->post_title; ?></h2>
     <?php do_action('yith_wcevti_default_html_after_title', $post) ?>
    </div>

    As you see we only added the do_action('yith_wcevti_default_html_after_title', $post) hook. We will apply this hook on the next plugin version.

    Now from your functions.php from your active theme add the following code:

    if ( ! function_exists( 'set_after_title_template' ) ) {
    	function set_after_title_template( $post ) {
    	    $order_id = get_post_meta($post->ID, 'wc_order_id', true);
    	    $order = wc_get_order($order_id);
    
    	    $first_name = $order->get_billing_first_name();
    
    		echo ' purchased by '. $first_name;
    	}
    }
    add_action('yith_wcevti_default_html_after_title', 'set_after_title_template');

    Here we are getting the order info from ticket and getting the first name from billing order for example.

    Please try this and let me know if you find some problem.
    Regards.

    • This reply was modified 7 years, 1 month ago by YITHEMES.
    • This reply was modified 7 years, 1 month ago by YITHEMES.
    Thread Starter Erling

    (@erling)

    Thank you very much. I’m trying it immediately and looking forward to get it to work.

    But I get this error on the page:
    Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home2/ivbk/public_html/webshop/wp-content/themes/ribbon-lite/functions.php on line 563

    My line 563 is this line:
    function set_after_title_template( $post ) {

    Can you see what’s wrong?

    Plugin Author YITHEMES

    (@yithemes)

    Could be you are using an older PHP version, please check your PHP version. Make sure it is in version 5.4 or higher. If the problem still happening, try to add ‘public’ before function:
    public function set_after_title_template($post)

    Regards.

    Thread Starter Erling

    (@erling)

    I checked the PHP version on our site – it’s version 5.4.
    I added ‘public’ before – but now I get this error:

    Parse error: syntax error, unexpected ‘public’ (T_PUBLIC) in /home2/ivbk/public_html/webshop/wp-content/themes/ribbon-lite/functions.php on line 564

    Plugin Author YITHEMES

    (@yithemes)

    Maybe there is a missing closing bracket {}. Please check that you do not copy the code into another method. Make sure that the code is copied on the last of functions.php file only with the brackets specified on our new snippet.

    Thread Starter Erling

    (@erling)

    IT WORKS !
    Thank you so much. The mistake was that I copied it in a wrong place in the file. This is what happens for a non-coder.
    I guess you can easily give me a line I can add, if I would like to have first AND last name on the ticket?

    Plugin Author YITHEMES

    (@yithemes)

    Hi @erling,

    We′re glad it works. If you want to add the last name you can get it from order object…:
    $last_name = $order->get_billing_last_name();

    So just add $last_name on our snippet…:

    if ( ! function_exists( 'set_after_title_template' ) ) {
    	function set_after_title_template( $post ) {
    	    $order_id = get_post_meta($post->ID, 'wc_order_id', true);
    	    $order = wc_get_order($order_id);
    
    	    $first_name = $order->get_billing_first_name();
                $last_name = $order->get_billing_last_name();
    
    		echo ' purchased by '. $first_name . ' ' . $last_name;
    	}
    }
    add_action('yith_wcevti_default_html_after_title', 'set_after_title_template');

    Regards ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Name on the ticket?’ is closed to new replies.