[Resolved] Event Ticket Plus plugin shows at the end of each content template
This thread is resolved. Here is a description of the problem and solution.
Problem:
The user is using the Event Tickets plugin to sell tickets for events(custom post type). He displays the event using a content template and he got the list of tickets duplicated several times on the page.
Solution:
The Event Tickets plugin is hooking into "the_content" to display the list of tickets.
Toolset replaces the results of "the_ticket" filter with the generated markup from a content template.
Because the user was using content templates inside of the Event content template, the list was displayed after each content template.
To workaround this, instead of including the child content template, or the body with a block, use the wpv-post-body shortcode with the suppress_fitlers argument.
Then, at the bottom of the content template, where we want to display the list of tickets, include an empty content template with a block.
Future versions of Toolset Blocks will allow a content template to be included as a block and will allow us to suppress the filters on it.
This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Hi,
I have created a custom type which I would like to use as events. I have bought the plugin Event Tickets plus. Im using blocks and content templates. The problem is that the Event Ticket plus displays at the end of each content template
I found an old ticket with the same problem and it is marked as resolved. However, I cannot find any solution.
the ticket: https://toolset.com/forums/topic/event-tickets-keep-displaying-after-each-types-item-in-my-template/
One option is to rebuild the content templates into reusable blocks.
BR
Johan
I tried to find out where on your website but I could not find it quickly. The content template for "Aktiviteter" is using other templates and I am not sure if that's where I should look. I also see two Events plugins (one is probably depending on the other)
To better assist you with this issue, I have created a test site on our platform, please upload the Events plugin(only the required plugins) there and create a minimal test to reproduce this issue(1 custom post type, 1 content template, 1 post).
I'll take it from there and if I could not find a solution quickly, I'll escalate the ticket to our 2nd Tier or our compatibility team. You can log in to this test site with the following URL: hidden link
We might have a workaround solution, please check if it is viable for you.
The workaround is to insert a content template using a shortcode instead of a block. The shortcode will use the suppress_filters=true argument to disable "the_content" filter on it.
Check this content template hidden link
But, using a shortcode with suppress_filters=true seems to disable "the_content" filter on the parent content template too.
Is this workaround viable solution for you? If not, what would you expect to get on the frontend(the list of tickets only after the parent content template)?
Let me know your opinion, so I can escalate this ticket with the required details.
Hi,
When doing your work around the event did not show at all.
However,
I opened a ticket at the Event team as well. And I got this back
------
With not being familiar with Toolset and the language difference, I'm not sure exactly what's going on there. But, if I switch the "content template" setting to the other options, this does not occur. There may be something in this particular "content template" that is calling "the_content" again.
Can you provide a brief explanation about what the "content template" you have selected is doing?
------
Content templates are basically templates in general terms, they are used to display a post. Check our glossary article https://toolset.com/glossary/template/
I am sure that the Events plugin is also hooking into "the_content" hook with a higher priority than Toolset. This way, it displays its content after what is generated by WordPress(in this case by Toolset).
We offer the option "suppress_filters" to disable this functionality.
I hope this will help the Event team to understand how Toolset works.
I hope that you can ask the Event team, to tell you where are they hooking into "the_content", and if possible, how can we unhook it. That way, we can selectively(with custom code) disable their hook on the "child" content template, and leave it only for the parent content template. And that way, you will have only one "Tickets content" on your page.
I got the following answer back:
You can find the callback where our plugin adds the tickets to "the_content" in the following file: event-tickets/src/Tribe/Tickets.php
I have added the code below: Tickets.php
<?php
/**
* Provides functionality shared by all Event Tickets Plus ticketing providers.
*/
abstract class Tribe__Tickets_Plus__Tickets extends Tribe__Tickets__Tickets {
public function __construct() {
parent::__construct();
}
/**
* Processes the front-end tickets form data to handle requests common to all type of tickets.
*
* Children classes should call this method when overriding.
*/
public function process_front_end_tickets_form() {
$meta_store = new Tribe__Tickets_Plus__Meta__Storage();
$meta_store->maybe_set_attendee_meta_cookie();
}
/**
* Returns the amount of global stock set for the event.
*
* A positive value does not necessarily mean global stock is currently in effect;
* always combine a call to this method with a call to $this->uses_global_stock()!
*
* @since 4.6
*
* @param int $post_id
* @return int
*/
protected function global_stock_level( $post_id ) {
// In some cases (version mismatch with Event Tickets) the Global Stock class may not be available
if ( ! class_exists( 'Tribe__Tickets__Global_Stock' ) ) {
return 0;
}
$global_stock = new Tribe__Tickets__Global_Stock( $post_id );
return $global_stock->get_stock_level();
}
/**
* Hooks into tribe_tickets_ajax_refresh_tables
* to add the capacity table and total capacity line to the refreshed tables.
*
* @deprecated 4.6.2
* @since 4.6
*
* @param array $return Data to be returned to ajax function.
* @param int $post_id The post id of the event/post the ticket is attached to.
*
* @return array Data to return to ajax function.
*/
public function refresh_tables( $return, $post_id ) {
_deprecated_function( __METHOD__, '4.6.2', '' );
// Add the capacity table to the return
$return['capacity_table'] = tribe( 'tickets.admin.views' )->template( 'editor/capacity-table', null, false );
$return['total_capacity'] = tribe( 'tickets-plus.admin.views' )->template( 'editor/total-capacity', null, false );
return $return;
}
}
Our 2nd Tier has found a way to display only one list of tickets. The trick is to include the child content template with a shortcode and use the suppres_filters argument. Then include the post body without the argument.
Check this test page here hidden link
And the content template here hidden link
I hope that this is what you are asking for. Let me know if you have any further questions.
Hi, That solved one thing. The next problem is that the ticket blocks are not available within the content template. If it was, you could then place the ticket block, where you like on the page. Now you can not deiced where to place it. What do you need from the event ticket team to look at it?
BR
Johan
To place the tickets list somewhere on the page, you can use an empty content template, and place it where you want the list. Because the list is displayed after the "the_content" hook, it will be displayed for that content template. For other content templates, include them with a shortcode and use the suppress_filters argument.
From the Events team, I would like to know what code to use to unhook "the_content". They already shared the code that does that, but it is a class, and not an object. They can help to know what is the object to use. That way, we may unhook it with this sample code:
Hi,
This is what the Event team replied:
The Events Calendar
5:07 PM (5 hours ago)
to me, Johan
Hi again,
We are limited in the amount of support that we can provide for customizations like this. Unfortunately, after digging around the plugin code for some time, I am not able to provide an answer to your last question. I do see the class I referenced being used directly, and also see that it is extended using as "Tribe__Tickets_Plus__Tickets". However, I was not able to prevent the tickets form from displaying using any of the filters for "the_content" I could find related to these objects.
The actual ticket form output happens in the following template: event-tickets/src/views/blocks/tickets.php
I was able to prevent the tickets form from being output by using the following filter:
Thank you, this may be helpful if we don't find a solution and when we'll need a custom code solution.
I still believe we can get what you want by using a mix of the content template block and the shortcode workaround.
Please give an example from your website and tell where you would like to get the list of tickets and where you don't, I'll try from my side and check if we can find a solution that does not involve custom code.
Otherwise, I'll try to come up with a code snippet that can help.
Hi,
Please visit it is a test site so you can do what you like. hidden link
I wrote in a paragraph where I would like the ticket box
I will give you login so you can do your magic.
Please tell me how to provide the credentials in a secure way
It also looks like the view displays the ticket box.
BR
Johan
Credentials on your first message are still working for me. So, I analyzed the content template and indeed, there is a list that is displayed after the view "PostRelatedView"(ID: 1900). And a list displayed after the body content, that is added with a single field block.
I was able to remove the first list, right after the content body, by replacing the single field block with a shortcode that will display the body and suppress filters:
On the other hand, I was not able to remove the list from the "PostRelatedView", even if I used the suppress_filters argument. So, I added a custom CSS code to the content template to hide it. The CSS code is scoped to the content template and any view that is inside of it:
Then, I created an empty content template(EmptyContentTemplateToDisplayTicketsList) and I put it using a block in the place where you want the list to be shown.
Please check if this is what you would like to get hidden link