How can I include the front end tickets form in my page?

Home Forums Ticket Products Event Tickets Plus How can I include the front end tickets form in my page?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1137058
    keystoliteracy
    Participant

    I’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!

    #1137219
    Nico
    Member

    Hi 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,
    Nico

    #1138399
    keystoliteracy
    Participant

    I’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?

    #1138403
    keystoliteracy
    Participant

    I 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( “” );

    #1138558
    keystoliteracy
    Participant

    I 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,
    Abby

    #1139574
    Nico
    Member

    Thanks 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,
    Nico

    #1148212
    Support Droid
    Keymaster

    This 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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘How can I include the front end tickets form in my page?’ is closed to new replies.