Support

Home Forums Event Espresso Premium Changing Sort Order of Events in Cart

Changing Sort Order of Events in Cart

Posted: November 25, 2013 at 11:57 am

Viewing 4 reply threads


Ross Willits

November 25, 2013 at 11:57 am

I am trying to understand how items in the Shopping Cart are sorted.

Does EE use the Event Title, or the unique identifier to sort. If it’s the latter, how do I force items to sort to the bottom of a cart list?

Here’s a link to an event page where you can add multiple events and items to the cart. I’d like the “Add a Donation” and “Add a T-Shirt” to sort below the “Create-A-Play” event.
https://www.steppingstonetheatre.org/about/event-registration/?ee=137

Thank you.


Sidney Harrell

November 25, 2013 at 12:35 pm

It looks like it’s controlled by templates/shopping_cart.php line 34:

$sql .= " ORDER BY e.start_date ";

You could add some code in after line 36 when it has the results to take a specific event and move it to the end of the array, or use a custom php array sort to sort by an event meta key’s value. Or you could change the sort to sort by event id or event name.


Ross Willits

November 25, 2013 at 1:43 pm

If I were to change the “ORDER BY” in the shopping_cart.php file to be the Event Name, what would the field name be that would correspond to “”e.start_date” in the current cart?

Many thanks,
Ross


Sidney Harrell

November 25, 2013 at 4:29 pm

It would be “e.event_name”. If you wanted it to be in reverse, so that “A”‘s would be after “C”‘s, then it would be:

$sql .= " ORDER BY e.event_name DESC ";


Ross Willits

November 26, 2013 at 8:22 am

Worked like a charm! Many thanks!

Viewing 4 reply threads

The support post ‘Changing Sort Order of Events in Cart’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso