How to access Ticket Start and End Dates in my Theme

Home Forums Ticket Products Event Tickets Plus How to access Ticket Start and End Dates in my Theme

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #75644
    quantumdynamix
    Participant

    I am trying to display custom messages on-screen when tickets have not gone on sale yet, and when ticket sales have passed their end date.

    For example, if tickets go on sale on December 1st, if you visit the event on the site, I’d like some sort of message that says “Tickets go on sale on December 1, 2013”. And if November 1st was the final day of ticket sales, I want to tell the site’s visitors “Sorry, tickets are no longer available.”

    Is there some way for my template file for my event details page to get access to the Start and End dates of ticket sales so that I can build some conditional logic to display various messages based on those dates?

    #75924
    quantumdynamix
    Participant

    Sorry for the bump, but this is one of the last issues left to resolve on a site that we are trying to launch tomorrow. Any method for getting my page templates to access the start and end sale dates for tickets?

    #75942
    Kelly
    Participant

    Hi, quantumdynamix. This is a great question! 🙂

    I guess, you’d basically need to work backwards, i.e. get the product(s) associated with the event, then pull the ticket start/end sale dates from there. The first part could be done with Woot! (http://wordpress.org/plugins/woot-library/) using woot_get_tickets( false ) and the second bit by looping through the array and checking the post meta date for the start/end sale dates.

    That’s kind of technical/high level, but hopefully, that gets you pointed in the right direction as you investigate further. Admittedly, this is a bit outside the scope of support that we can provide here on the forums, but we’d like to make sure that you don’t get stuck along the way. 🙂

    Hope that helps!

    #76421
    quantumdynamix
    Participant

    FYI in case someone else is looking to do the same thing, here is what we did on the single-event.php file:

    id);
    if(!isset($saleStart)){
    $saleStart = new DateTime($productMeta[“_ticket_start_date”][0]);
    }else{
    $tempStart = new DateTime($productMeta[“_ticket_start_date”][0]);
    if($tempStart $saleEnd){
    $saleEnd = $tempEnd;
    }
    }
    }
    $rightNow = new DateTime(‘NOW’);
    if($rightNow < $saleStart){
    //tickets are not on sale yet.
    echo "Tickets”;
    echo “TICKETS NOT ON SALE YET“;
    }else if($rightNow > $saleEnd){
    //tickets are no longer on sale.
    echo “Tickets”;
    echo “TICKETS ARE NO LONGER ON SALE“;
    }else{
    //tickets are on sale now
    do_action( ‘tribe_events_single_event_after_the_meta’ );
    echo get_post_meta( get_the_ID(), ‘start_date’, true);
    }
    }
    ?>

    Hope this helps someone.

    #76423
    quantumdynamix
    Participant

    Let’s try this again:

    id);
    if(!isset($saleStart)){
    $saleStart = new DateTime($productMeta["_ticket_start_date"][0]);
    }else{
    $tempStart = new DateTime($productMeta["_ticket_start_date"][0]);
    if($tempStart $saleEnd){
    $saleEnd = $tempEnd;
    }
    }
    }
    $rightNow = new DateTime('NOW');
    if($rightNow < $saleStart){
    echo "Tickets";
    echo "TICKETS NOT ON SALE YET";
    }else if($rightNow > $saleEnd){
    echo "Tickets";
    echo "TICKETS ARE NO LONGER ON SALE";
    }else{
    do_action( 'tribe_events_single_event_after_the_meta' );
    echo get_post_meta( get_the_ID(), ‘start_date’, true);
    }
    }
    ?>

    #76424
    quantumdynamix
    Participant

    Ok, is there a way to post code on these forums without everything breaking? It is stripping out a lot of the code I am trying to post.

    #76432
    Kelly
    Participant

    Sorry about that! Your best bet (and what we do), is create a paste (at pastebin) or gist (at github) for them and then put the link in the post.

    We hope to have a better solution soon, but we’re not close enough to have a launch date for it. Believe me that you are not alone! 🙂

    #76436
    quantumdynamix
    Participant

    Ok, so view the link below to see how it works. This fix uses the Woot Libraries plugin, and the code appears in the single-event.php file where you want to display your ticketing information.

    http://pastebin.com/AqP21tjh

    #76438
    Kelly
    Participant

    That’s great news, quantumdynamix. Thanks so much for sharing the solution with us!

    Since you’re set here, I’ll go ahead and close this thread. Please start a new one if anything else comes up. 🙂

    #982015
    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 10 posts - 1 through 10 (of 10 total)
  • The topic ‘How to access Ticket Start and End Dates in my Theme’ is closed to new replies.