Get ticket in order

Home Forums Ticket Products Event Tickets Plus Get ticket in order

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1242526
    Riccardo
    Participant

    Hi,
    I want to add a custom message if in my order there is a ticket.
    How can I search, query if there is a ticket in my order?
    thanks

    #1242756
    Cliff
    Member

    Hi, Riccardo.

    Could you please be more specific about what you’re wanting to add, where in the email, and to which email? Are you possibly talking about the WooCommerce order email that gets sent in addition to the separate Tickets email?

    #1242803
    Riccardo
    Participant

    Hi Cliff,
    in the email customer completed order, if there are tickets a want add:
    “in the next email we will send the tickets”
    If there are not ticket I want don’t show the message

    thanks

    #1242976
    Riccardo
    Participant

    Hi Cliff,
    this is the solution I try to write, it works… maybe you can help me to simplify or there is something more simple
    thanks

    
    function controllo_biglietti_ordine($order){
    	
    	
    	global $woocommerce;
        $order_controllo   = new WC_Order( $order );
    	
    	//retrieve the order id
    	$order_controllo = trim(str_replace('#', '',  $order_controllo->get_order_number()));
    	
    	
    	// array to control the results
    	$array_controllo = array();
    	
    	
    	  if ( sizeof( $order->get_items() ) > 0 ) {
    
            foreach ( $order->get_items() as $item ) {
    
                if ( $item['qty'] ) {
    
                  
                    
    
                    $_product   = $order->get_product_from_item( $item );
                    $item_name  = $item['name'];
    				
    				$ticket_meta = get_post_meta( $item['product_id'] );
    		
    			
    			
    				$trova_dentro_array = '_tribe_wooticket_for_event';
    				
    				
    				if (array_key_exists($trova_dentro_array,$ticket_meta)){
    					
    					// if there is a ticket
    					$controllo_biglietto = 1;
    					
    					
    				}
    				
    				else {
    					
    					// if it isn't a ticket
    					$controllo_biglietto = 0;
    				}
    				
    				$array_controllo[] .= $controllo_biglietto;
    				
    			}
    				
    		}
    	
    }
    	
    	
    	if (in_array('1',$array_controllo)){
    		
    		$risultato_controllo = 1;
    		
    	}
    	else {
    		
    		$risultato_controllo = 0;
    	}
    	
    	
    	return $risultato_controllo;
    	
    }
    

    then in my email template

      
    // PETTE retrieve result of function
    	$variabile_controllo_biglietto = controllo_biglietti_ordine($order);
    	
    	// if the result is 1
    	if ($variabile_controllo_biglietto == 1){
    		
    	
    echo 'Hi, the tickets will send with next email. Thanks';
    	}
    	
    • This reply was modified 7 years, 2 months ago by Riccardo. Reason: Edit the code
    #1243265
    Cliff
    Member

    Thanks for that, Riccardo.

    If that’s working for you, it looks okay to me.

    Please let me know if there’s more I can help with here.

    #1243268
    Riccardo
    Participant

    Hi Cliff,
    I you haven’t suggestion or some improvements, you can close the thread!
    thanks

    #1243331
    Cliff
    Member

    Thanks for that update, Riccardo.

    Have a great rest of your week!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Get ticket in order’ is closed to new replies.