Home › Forums › Ticket Products › Event Tickets Plus › Add buy button to front
- This topic has 6 replies, 2 voices, and was last updated 9 years, 11 months ago by
Brook.
-
AuthorPosts
-
May 17, 2016 at 2:23 am #1115264
James
ParticipantHi,
I have the free/normal version of Events Calender and bought the tickets plugin for my client.
The buy button shows fine on the event itself when you click “read more”. Is it possible to have the woocommerce buy button on the event in list mode? When viewing the events in list mode (not month or day mode) you should have a buy button next to the event. This would make the checkout process a tad quicker (from experience people like moaning about how long it takes). Let me know if possible please!
Also with the calender is it possible to disable the view by month and day options? I want only the list option to be available, and would rather disable them rather than hide them with CSS.
Thanks for your help guys!
May 17, 2016 at 7:54 am #1115351Brook
ParticipantHowdy James,
I would love to help you with this.
It is possible to add a Buy Button to the list view. It will require some custom coding though. Do you want this button to just take you to the single events page, but be an anchor link that scrolls down to the tickets area? If so this is pretty easy. Checkout our Themer’s Guide for a walkthrough on how to modify the look of thigns including inserting your own content. Once familiar with that create an override for /the-events-calendar/src/views/list/single-event.php . As you can see that file is the template for each item in list view, so anything you insert here will appear on each event.
If you are hoping the button will add a ticket directly to the cart it gets more complicated. What happens when there are multiple tickets available for a single event, which one does it add? How many tickets does it add? These are questions you’ll have to answer before designing the button. From there you can use our API and write a little bit of PHP to make this happen. If this you chose let me know and I can give you a general overview of the code here.
Also with the calender is it possible to disable the view by month and day options? I want only the list option to be available, and would rather disable them rather than hide them with CSS.
That is absolutely possible. Checkout WP-Admin > Events > Settings > Display . Uncheck any views from “Enable event views” that you wish to hide and click Save.
Does that all make sense? Will that work for you? Please let me know.
Cheers!
– Brook
May 17, 2016 at 8:45 am #1115373James
ParticipantThanks, the second issue is now solved.
Right, what I want to do is add an “add to cart” button for each event in list view. So each event in list view will have an add to cart button next to it. I want the button to add the correct event ticket to the cart. Each event will always only have 1 kind of ticket available, so it might be possible.
Thanks for your quick reply by the way!
May 18, 2016 at 12:56 pm #1116097Brook
ParticipantThanks for getting back to me. In that case I would do the following:
- Create the override for /the-events-calendar/src/views/list/single-event.php
- Use Tribe__Tickets_Plus__Commerce__WooCommerce__Main::instance()->get_tickets_ids( $eventid ) to get all the ticket ids for the event. This will return an array, just use the first items in it since you will only have on ticket per event. Assign this to a variable like $ticketid .
- The easiest way to insert an add to cart button from here is the Woo shortcodes like [add_to_cart id=”99″]. So you might just do do_shortcode(‘[add_to_cart id=”‘.$ticketid.'”]’); Or if you prefer a different method for inserting the add to cart button use that instead.
And there you have it! You should be ready to roll. Please let me know if you have any questions. Obviously the above will require some testing and tweaking to get working right on your setup, but that should get you rolling in the right direction.
Cheers!
– Brook
May 19, 2016 at 3:34 am #1116298James
ParticipantCall me silly but I haven’t overridden a plugin file before (this is my first freelance project!) so could you let me know how? The rest should be easy enough.
May 19, 2016 at 3:51 am #1116299James
ParticipantIgnore that – I got it working with the file path [your-theme]/tribe-events/list/single-event.php
May 19, 2016 at 10:04 am #1116534Brook
ParticipantI am happy to hear that James! The very specific folder structure can be a pain at times, its a necessary evil for theme overrides.
Thanks for getting back. Let us know if you ever need anything else. Cheers!
– Brook
-
AuthorPosts
- The topic ‘Add buy button to front’ is closed to new replies.
