Separate Booking Page

This topic contains 2 replies, has 2 voices, and was last updated by  Paul Oaten 9 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #11643

    Hi Stephen,

    I know I’ve just done some work on getting the booking form into a sidebar, but it occurs to me that I might want to move the booking form (as it’s getting a little on the large side) to a separate page altogether. Would this be possible? Is there an example I could follow? I assume it would involve passing params to the generic booking page so that the correct course and date is pre-selected…

    Any advice appreciated.

    • This topic was modified 9 years, 9 months ago by  Paul Oaten. Reason: typo
    Paul Oaten
    #11645

    Yes you can.

    Disabling the default booking form
    To prevent the booking form from being automatically added to the event page, see this page.

    Displaying the form on page

    If you know the event ID (I know this doesn’t apply to you, but I’m including it for others). The simpliest thing to do is create a page and use the shortcode has demonstrated on this page.

    Otherwise, if you not know a priori the event ID, then instead create a page template with the following:

    $event_id = get_query_var( 'event_id' ); 
    echo eo_get_booking_form( $event_id );

    wherever you want the form to go. You can change the query variable event_id to whatever you like (but it shouldn’t clash with an existing query variable). Next register the query variable:

    function my_register_event_id_query_var( $qvars ){
        $qvars[] = 'event_id';
        return $qvars;
    }
    add_filter('query_vars', 'my_register_event_id_query_var' );  

    This can go in your theme’s functions.php but should go in a dedicated plug-in (for portability sake). Now if you got to [page-url]/?event_id[event-ID] you’ll see the appropriate booking form.

    Pretty permalinks (Optional)
    Lastly we can add a rewrite rule so we can use a ‘pretty’ url. As before this should go in a dedicated plug-in. You’ll need to specify the (fully) page slug used, and the page ID. If you’ve changed the query variable from event_id, you’ll need to change it here also:

    function my_booking_page_rewrite_rule(){
        $page_slug = 'booking';
        $page_id = 2531;
        add_rewrite_rule(
            '^'.$page_slug.'/event_id/(\d*)?',
            'index.php?page_id='.$page_id.'=&event_id=$matches[1]',
            'top'
        );
    }
    add_action( 'init', 'my_booking_page_rewrite_rule' );

    Lastly go to Settings > Permalinks and click “Save Changes”. Now you’ll find [page-url]/event_id/[event-id] takes you to the booking page.

    Note: by default users will be redirected back to the booking form with an appropriate message. When using a dedicated booking page (using the template) that unfortunately won’t work. But you can set up a second page as a dedicated confirmation page: http://wp-event-organiser.com/forums/topic/dedicated-bookings-landingpage-possible/.

    Stephen Harris
    #11647

    Oustanding – I will test this and update the thread once I have it working.
    Thx Stephen

    Paul Oaten
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.