Sort Products by Date?

Home Forums Calendar Products Events Calendar PRO Sort Products by Date?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #998283
    Lori
    Participant

    I am using Events Calendar Pro with WooTickets. Once I’ve created an Event with a Ticket, the Ticket becomes a Product. So far so good. I have the Products (tickets) displayed on my page http://www.dbbrewtours.com/tickets. Also not bad. My question is this: How can I get the Tickets (Products) to display by date?

    I’m thinking that surely, since Woocommerce Tickets and Events Calendar Pro are intended to work together in exactly this way, there must be a way to do it, but I can’t figure out how. (I’ve tried all the options under product sorting in WooCommerce Display Settings, but none are making them appear in date order.)

    Thanks in advance.

    #998598
    George
    Participant

    Hey Lori,

    Thanks for reaching out. I’m curious about a few things here: first, can you clarify exactly what you mean by this comment?

    I’m thinking that surely, since Woocommerce Tickets and Events Calendar Pro are intended to work together in exactly this way, there must be a way to do it,

    What way do you mean, specifically? I just want to be certain of this because you might be referring to something that is not, in fact, something intended to work a certain way, which would then require a different approach than if you’re referring to something that is supposed to be working a certain way.

    Next, can you clarify exactly how you made the /tickets page on your site?

    Thank you in advance for providing more information on both of these points. In closing, for now, I should point out that this is mostly a customization question. No worries! I’m still here to help out as much as I can 🙂 But just wanted to note this, and to note the related fact that we don’t offer any support for customizations here.

    — George

    #998617
    Lori
    Participant

    Hi George,

    Please accept my apology if I’m misunderstanding. I was under the impression that Woocommerce Tickets was intended to work with Events Calendar/Pro. (EventsCalendar.com—products—tickets—WooCommerce Platform—WooCommerce Tickets Add-On).

    The business I’m building the site for is a brew tour company. My goal was to be able to have events to which tickets are sold, that also appear on a calendar.

    After reading through the New User Primers for both Woocommerce Tickets and Events Calendar Pro, what I did was under Events, chose Add Event. Then added the Ticket to that event (inside the Event Adding area). This had two effects: 1) It created an event on the calendar which, if clicked, offers a ticket to buy (yay!) 2) It created, in WooCommerce, a Product called Tickets.

    So then, in WooCommerce–Settings–Products–Display, I set it up so that my Shop Page is http://www.dbbrewtours.com/tickets and Shop Page Display is Show Products, and Default Category Display is Show Products. (I did not need to sort categories because I have only one category to display: Tickets.) So far, so good: The page http://www.dbbrewtours.com/tickets page DOES display all the Tickets I have set up (originally set up under Add Event in Events Calendar Pro.)

    The only problem is that there is no way to sort the Tickets (Products) displayed on the Shop Page (called Tickets) in date order.

    Maybe there was a different way I was supposed to set up these tickets and events in the first place? But I don’t think so because I really did read the New User Primers thoroughly. (But I could have made a mistake!)

    A different solution for this would be if there was a shortcode that allowed me to display the Calendar as a list on one page and as a normal calendar grid on another, but since there’s not, I was figuring this would be a good way to have a List of all Tickets (Products) available. If only they could be sorted by date. 🙁

    This “seems to me” like something the two would normally do together, since the calendar is a calendar and tickets to things are generally sold for a specific date or time frame. And the marketing of Woocommerce Tickets was in the spirit of “Hey, wanna sell tickets to events from this here calendar?” However, if it is a customization I apologize for my confusion.

    Regardless of what it’s called, I genuinely appreciate your time and expertise. This is my first experience with these programs (Events Calendar Pro and WooCommerce Tickets), but I foresee the potential for me to become a huge fan of using them for my clients’ sites, as several upcoming projects have needs for these features.

    Thanks.

    #998787
    George
    Participant

    Hey Lori,

    Thanks for elaborating on some of the things you meant here, it definitely helps. With this extra info I can hopefully provide a more helpful response here 🙂

    After reading through the New User Primers for both Woocommerce Tickets and Events Calendar Pro, what I did was under Events, chose Add Event. Then added the Ticket to that event (inside the Event Adding area). This had two effects: 1) It created an event on the calendar which, if clicked, offers a ticket to buy (yay!) 2) It created, in WooCommerce, a Product called Tickets.

    Yes – these are things that are meant to be possible by design.

    So then, in WooCommerce–Settings–Products–Display, I set it up so that my Shop Page is http://www.dbbrewtours.com/tickets and Shop Page Display is Show Products, and Default Category Display is Show Products. (I did not need to sort categories because I have only one category to display: Tickets.) So far, so good: The page http://www.dbbrewtours.com/tickets page DOES display all the Tickets I have set up (originally set up under Add Event in Events Calendar Pro.)

    This is where things fall outside the scope of our WooCommerce Tickets add-on.
    The reason why is because the WooCommerce Tickets add-on is not meant to be used for creating standalone products that display outside the context of events. Tickets are “Products”, yes, but are meant to be more a part of an Event. So, in other words, the plugin’s design is built around displaying a list of upcoming events for which there are tickets, rather than what you’re doing, which is to display upcoming tickets that exist, but with no context of the event they are tickets for.

    Does that make sense at all? I’m sorry if that only adds to the confusion, but the main takeaway from that distinction I made is that you will not be able to build custom Tickets displays like you are trying to do without custom code.

    I’m sorry to bear that news, especially since we don’t technically offer any support for custom code here – but if you’re already most of the way there with the /tickets/ page on your site, then this might be a pretty simple customization to make after all, and I’d love to at least try and help! 🙂

    Customizing the Tickets Display to Sort by Date

    The first thing to try here is to see if the “Default Product Sorting” option in WooCommerce works for you. I’m sorry if it doesn’t, or if you’ve already tried this, but the option is in WooCommerce → Settings → Products → Display. There are date-related options worth trying out, as noted in this screenshot: https://cloudup.com/cgS4Z6VEUzQ.

    If that doesn’t help, the only alternative I can think of is to filter the query using pre_get_posts. Pre_get_posts is a powerful filter and you should use it with caution, and read up a bit about it here → https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

    You could then try adding code like the following to your theme’s functions.php file, and see if it helps at all.

    This code, in theory, sets the ‘orderby’ query parameter to ‘date’, which is what you’re trying to do. Then, it sets the ‘order’ parameter to DESC, though you can set this to ASC instead by simply replacing DESC in the code with ASC. This will switch the display of the ordered items from descending to ascending, or vice-versa.


    add_action( 'pre_get_posts', 'tribe_998283_pre_get_products' );

    function tribe_998283_pre_get_products( $query ) {

    if ( is_admin() || is_main_query() ) {
    return $query;
    }

    if ( ! isset( $query->query['post_type'] ) || 'product' !== $query->query['post_type'] ) {
    return $query;
    }

    $query->set( 'orderby', 'date' );
    $query->set( 'order', 'DESC' );

    return $query;
    }

    If neither of these things work, then unfortunately, there is little left that we ourselves could offer here and your best option would be to contact WooCommerce support or hire someone to make a more involved a customization for you here.

    Hopefully something here does help, though – let us know!

    Thanks,
    George

    #999193
    Lori
    Participant

    Hi George,

    Thank you so very much for the very detailed reply! After investigating all of the options you mentioned, I’ve decided to just eliminate the listing of tickets as products on the shop page. (I am not comfortable messing with the codes to the above extent, and the simpler options didn’t pan out.)

    The only problem I’m left with is that now, I just want to make the “shop” page point to “calendar” (because when someone clicks “find more tickets,” it still has to go somewhere.) However, even though all the rest of the pages on the entire site come up as an option, the Calendar page does not!

    (This is weird, as it does exist: http://www.dbbrewtours.com/calendar but it doesn’t even show up as a page option in my Pages or when creating a menu. I temporarily added it to the menu by using “Add Custom Link” to menu.)

    Thanks again for ALL the time and effort you’ve put into helping!

    #999266
    Lori
    Participant

    Please disregard this question, as it does not apply to the situation we were talking about. While I do still have a problem where my calendar only appears when you actually type the address, I just realized that it would be pointless to have the products show there because I’m trying to avoid listing them altogether.

    Thanks again!

    • This reply was modified 10 years, 8 months ago by Lori.
    #999436
    George
    Participant

    Thanks for the update Lori! It sounds from your last reply like you’re all set with these issues, so I will proceed with closing up this thread for good.

    But if you have any other questions or concerns, don’t hesitate to come back and open a new thread any time!

    Cheers,
    George

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Sort Products by Date?’ is closed to new replies.