Home › Forums › Ticket Products › Event Tickets Plus › Get ticket in order
- This topic has 7 replies, 3 voices, and was last updated 7 years, 2 months ago by Cliff.
-
AuthorPosts
-
February 20, 2017 at 4:02 pm #1242526RiccardoParticipant
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?
thanksFebruary 20, 2017 at 11:03 pm #1242756CliffMemberHi, 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?
February 21, 2017 at 1:09 am #1242803RiccardoParticipantHi 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 messagethanks
February 21, 2017 at 8:13 am #1242976RiccardoParticipantHi Cliff,
this is the solution I try to write, it works… maybe you can help me to simplify or there is something more simple
thanksfunction 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
February 21, 2017 at 12:39 pm #1243265CliffMemberThanks 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.
February 21, 2017 at 12:41 pm #1243268RiccardoParticipantHi Cliff,
I you haven’t suggestion or some improvements, you can close the thread!
thanksFebruary 21, 2017 at 2:29 pm #1243331CliffMemberThanks for that update, Riccardo.
Have a great rest of your week!
-
AuthorPosts
- The topic ‘Get ticket in order’ is closed to new replies.