Home › Forums › Calendar Products › Events Calendar PRO › Payment Method on Ticket
- This topic has 13 replies, 2 voices, and was last updated 6 years, 8 months ago by Karl Edy.
-
AuthorPosts
-
July 25, 2017 at 2:41 am #1325645Karl EdyParticipant
Dear Support,
I’d like to display the payment Method on the Tickets of the customers.
I tried to put it in the email.php like so:
echo '<p><strong>Payment Type:</strong> ' . $order->payment_method_title . '</p>';
but this doesn’t work.any help?
thanks!
July 26, 2017 at 2:53 pm #1326641BarryMemberHi Karl,
Thanks for posting!
Please note however that the degree of support we can provide for custom dev tasks like this does tend to be on the limited side. If I can, though, I’d be happy to point you in the right direction.
Within the ticket loop contained in tickets/email.php you can access $ticket[‘ticket_id’]. Using this, you can obtain the order ID:
$order_id = get_post_meta( $ticket['ticket_id'], Tribe__Tickets_Plus__Commerce__WooCommerce__Main::ATTENDEE_ORDER_KEY, true );
You can then take the order ID and use the WooCommerce API to obtain information about the order (please see their docs for more detail on that process).
Does that help at all?
July 26, 2017 at 6:22 pm #1326688Karl EdyParticipantHello,
I tried it like the code below, but it doesn’t work.
If I confirm the ticket via WooCommerce it redirects me to an extra page where I see the ticket, but without any information about anything. (see screenshot) It neither sends the ticket per email.Code:
$order_id = get_post_meta( $ticket['ticket_id'], Tribe__Tickets_Plus__Commerce__WooCommerce__Main::ATTENDEE_ORDER_KEY, true ); $order = wc_get_order( $order_id ); $order_data = $order->get_data(); $order_payment_method = $order_data['payment_method']; echo $order_payment_method;
Thank you for your help!
July 27, 2017 at 8:12 am #1326908BarryMemberHi Karl,
If I confirm the ticket via WooCommerce it redirects me to an extra page where I see the ticket
This is really strange as, by default, this doesn’t normally happen.
Instead, the expected behaviour is that after going through checkout the customer will ultimately see an order confirmation page – but this does not include the actual tickets as per your screenshot.
Do you have customizations in place to achieve this? If so, might they be interfering with the normal dispatch of the ticket emails?
July 28, 2017 at 7:18 am #1327391Karl EdyParticipantHi Barry,
At first, thank you for your help!
I managed to get the payment method working in the ticket email, but now i get an error if i want to “Download a PDF copy of this ticket”. I have the tribe-ext-view-tickets plugin installed.
error:
Fatal error: Uncaught Error: Call to a member function get_data() on boolean in /home/.sites/856/site2268/web/wp-content/themes/unite/tribe-events/tickets/email.php:320 Stack trace: #0 /home/.sites/856/site2268/web/wp-content/plugins/event-tickets/src/template-tags/tickets.php(574): include() #1 /home/.sites/856/site2268/web/wp-content/plugins/event-tickets/src/Tribe/Tickets.php(1264): tribe_tickets_get_template_part(‘tickets/email’, NULL, Array, false) #2 /home/.sites/856/site2268/web/wp-content/plugins/tribe-ext-view-tickets/index.php(160): Tribe__Tickets__Tickets->generate_tickets_email_content(Array) #3 /home/.sites/856/site2268/web/wp-includes/class-wp-hook.php(298): Tribe__Extension__View_Print_Tickets->show_ticket_page(”) #4 /home/.sites/856/site2268/web/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array) #5 /home/.sites/856/site2268/web/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #6 /home/.sites/856/site2268/web/wp-settings.php(469): do_action(‘wp_loaded’) #7 /home/.sites/856/site22 in /home/.sites/856/site2268/web/wp-content/themes/unite/tribe-events/tickets/email.php on line 320
it seems to increment the tribe_view_ticket_order by 1 if i want to download the ticket.
as seen in the url: /?tribe_view_ticket_order=2294&tribe_pdf_ticket=truehere is the code on line 320 in my email.php:
312 # get payment_method 313 //start 314 $order_id = get_post( 315 $ticket['order_id'], 316 Tribe__Tickets_Plus__Commerce__WooCommerce__Main::ATTENDEE_ORDER_KEY, 317 true 318 ); 319 $order = wc_get_order($order_id); 320 $order_data = $order->get_data(); 321 $order_payment_method = $order_data['payment_method']; 322 //end
I then echo the $order_payment_method in an if statement to get some text if it’s cash on delivery (cod):
if (strcmp($order_payment_method,'cod')==0) { echo "<p>Bitte bezahlen Sie Ihr Ticket beim Eintreffen!</p>"; } else { echo 'Bereits bezahlt!'; };
July 28, 2017 at 2:44 pm #1327695BarryMemberInteresting problem!
WooCommerce won’t provide the order object until after post types have been registered, which makes sense on a number of levels. If wc_get_order() is called before that point in time it will return false instead of an order object, which would account for the error you are experiencing.
To avoid the error you could test to see if you have a valid result before trying to print the payment method, ie:
$order = wc_get_order($order_id); if ( $order ) { // Code to fetch and display // the payment method }
Of course, the payment method will be missing in those cases where the PDF is downloaded. I’m not sure how much of a problem that may or may not be for you?
August 1, 2017 at 2:12 am #1328652Karl EdyParticipantThank you, but that doesn’t suit my needs.
Yes your solution avoids the error, but I need the paymentmethod on the ticket. Also on the PDF ticket.
do you have another workaround for me?
thank you in advance!
August 1, 2017 at 7:24 am #1328746BarryMemberOK, how about revising that snippet (in your email template) to the following:
$order = wc_get_order( $ticket['order_id'] ); if ( $order ) { $order_data = $order->get_data(); $order_payment_method = $order_data['payment_method']; echo $order_payment_method; }
August 1, 2017 at 9:06 am #1328795Karl EdyParticipantHi please delete my previous answer. this was Carmens fault.
And no, that doesn’t solve the problem..
August 1, 2017 at 2:09 pm #1329060BarryMemberYour other post has been deleted 🙂
Re the problem at hand, let’s switch from obtaining $ticket[‘order_id’] to grabbing $ticket[‘order_id_display’] instead. That certainly seems to work for me, for both the regular ticket email and for the PDFs, too.
August 2, 2017 at 12:41 am #1329304Karl EdyParticipantI do not get data with $ticket[‘order_id_display’] …
August 2, 2017 at 7:09 am #1329411BarryMemberSeems fine to me – are you mixing and matching WooCommerce tickets with RSVPs perhaps?
Either way, I’m sorry to say we’re pretty much at the end of what we can do to help you here: as noted at the start, the degree of support we can offer for custom dev tasks tends to be limited so all I can hope is that the above at least gives you a starting point and you can take things forward under your own steam and iron out any further problems from there.
Remember that, if you need more help than we can provide here (with custom development in particular) there are plenty of folks who can help:
http://theeventscalendar.com/find-a-customizer
Good luck with the project 🙂
August 24, 2017 at 9:35 am #1339807Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Payment Method on Ticket’ is closed to new replies.