Home › Forums › Ticket Products › Event Tickets Plus › How to access Ticket Start and End Dates in my Theme
- This topic has 9 replies, 3 voices, and was last updated 8 years, 10 months ago by Support Droid.
-
AuthorPosts
-
November 11, 2013 at 8:21 am #75644quantumdynamixParticipant
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?
November 12, 2013 at 3:26 pm #75924quantumdynamixParticipantSorry 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?
November 12, 2013 at 3:58 pm #75942KellyParticipantHi, 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!
November 14, 2013 at 6:28 am #76421quantumdynamixParticipantFYI 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.
November 14, 2013 at 6:30 am #76423quantumdynamixParticipantLet’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);
}
}
?>November 14, 2013 at 6:32 am #76424quantumdynamixParticipantOk, 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.
November 14, 2013 at 6:53 am #76432KellyParticipantSorry 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! 🙂
November 14, 2013 at 6:57 am #76436quantumdynamixParticipantOk, 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.
November 14, 2013 at 7:04 am #76438KellyParticipantThat’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. 🙂
July 7, 2015 at 6:29 am #982015Support DroidKeymasterThis 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. -
AuthorPosts
- The topic ‘How to access Ticket Start and End Dates in my Theme’ is closed to new replies.