Home › Forums › Ticket Products › Event Tickets Plus › How can I include the front end tickets form in my page?
- This topic has 7 replies, 4 voices, and was last updated 9 years, 8 months ago by
keystoliteracy.
-
AuthorPosts
-
July 7, 2016 at 7:10 pm #1137058
keystoliteracy
ParticipantI’m using Event Tickets Plus with a custom post type I created called workshop.
I’ve got a single-workshop.php that displays my custom post type.
I want to add the front end tickets form to the bottom (without calling the_content() ), is there a shortcode I should be using for this? Or…?
Thanks!
July 8, 2016 at 7:46 am #1137219Nico
MemberHi there Abby,
Thanks for reaching out to us! Interesting questions indeed 🙂
This is possible you just need to remove the_content filter and re-hook the display function into another filter or action:
/* Re-hook WooTickets form */
function tribe_rehook_tickets_form ( ) {if ( ! class_exists('Tribe__Tickets_Plus__Commerce__WooCommerce__Main') ) return;
$tickets = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
// prevent form to be printed in the_content
remove_filter( 'the_content', array( $tickets, 'front_end_tickets_form_in_content' ) );// filter
// add_filter( 'custom_fiter', array( $tickets, 'front_end_tickets_form_in_content' ) );// action
add_action( 'custom_action', array( $tickets, 'front_end_tickets_form' ) );
}add_action ( 'init', 'tribe_rehook_tickets_form' );
Insert the script above in your theme’s (or custom theme’s) functions.php file! The script assumes you are using WooCommerce as the e-commerce engine, if that’s not the case we need to change the class name.
Please let me know about it and I can adjust the script for you,
Best,
NicoJuly 11, 2016 at 2:40 pm #1138399keystoliteracy
ParticipantI’m afraid I don’t understand, what code would I write in my custom_action?
And do I have to do it as a filter? Is there a shortcode or php code I can use within the template I’m creating to place it where I want it inserted?
July 11, 2016 at 3:00 pm #1138403keystoliteracy
ParticipantI added this code into my page template and this seems to work – is this the right way I should be doing it?
if ( ! class_exists(‘Tribe__Tickets_Plus__Commerce__WooCommerce__Main’) ) return;
$tickets = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
$tickets->front_end_tickets_form( “” );-
This reply was modified 9 years, 9 months ago by
keystoliteracy.
July 12, 2016 at 12:29 am #1138558keystoliteracy
ParticipantI just noticed I’m also getting this when I list out my events:
“You have 3 Tickets for this Event. View your Tickets”
Can you tell me how to unhook that as well?
Thank you,
AbbyJuly 14, 2016 at 5:35 am #1139574Nico
MemberThanks for following up Abby and sorry for the delay in my reply!
Let’s do the following, please update the snippet I sent to this:
/* Re-hook WooTickets form */
function tribe_rehook_tickets_form ( ) {if ( ! class_exists('Tribe__Tickets_Plus__Commerce__WooCommerce__Main') ) return;
$tickets = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
$tickets_view = Tribe__Tickets__Tickets_View::instance();// prevent form to be printed in the_content
remove_filter( 'the_content', array( $tickets, 'front_end_tickets_form_in_content' ) );// re-hook tickets form to custom action
add_action( 'custom_tickets', array( $tickets, 'front_end_tickets_form' ) );// prevent the tickets link section to be printed in the_content
remove_filter( 'the_content', array( $tickets_view, 'inject_link_template_the_content' ), 9 );
}add_action ( 'init', 'tribe_rehook_tickets_form' );
And add the following line in your template to fire the tickets form action:
<?php do_action('custom_tickets'); ?>
This is a better way of doing this than adding the code directly into the template as you mention in a previous reply.
Regarding the ‘view your tickets’ part, I added a line in the snippet to remove the filter for that.
Please give this a try and let me know if it works as expected,
Best,
NicoAugust 5, 2016 at 9:35 am #1148212Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
This reply was modified 9 years, 9 months ago by
-
AuthorPosts
- The topic ‘How can I include the front end tickets form in my page?’ is closed to new replies.
