Support

Home Forums Event Espresso Premium change default URL for "Return to Event list depending on event-category

change default URL for "Return to Event list depending on event-category

Posted: May 16, 2020 at 7:56 am


efransen

May 16, 2020 at 7:56 am

Hi,
I have read this solution, but I was wondering if I could change the url depending on the parent event-category. When adding this code to the functions.php, the button ‘return to Events lists’ sends me to the domain.com, regardless of the category the event was in.
Does it have to do with the permalinks in anyway?
Any suggestions are welcome. Thanks in advanced!


// change default URL for "Return to Events List"
function ee_mer_change_event_list_url(){
if (has_term( 'courses-seminars', 'espresso_event_categories' ) ){
return 'https://domain.com/courses-seminars/';
} elseif (has_term( 'summerschool', 'espresso_event_categories' ) ) {
return 'https://domain.com/summer-school/';
} else {
return 'https://domain.com/';
}
}

add_filter( 'FHEE__EED_Multi_Event_Registration__set_definitions__events_list_url', 'ee_mer_change_event_list_url' );


Tony

  • Support Staff

May 18, 2020 at 5:16 am

Hi there,

It’s not an issue with permalinks, the problem is that when FHEE__EED_Multi_Event_Registration__set_definitions__events_list_url is fired, there is no post, so has_term() has nothing to work with.

The return to event list is displayed in 2 locations, 1 is on the modal when you add the individual events to the cart which I assume is the link you are wanting to change?

That’s done on an ajax request and has the event ID posted, so you can do something like this:

https://gist.github.com/Pebblo/14acf044ca0a4aef2cc417be742f7400

The second location is on the main ‘cart view’, which the above will leave as the default location.


efransen

May 19, 2020 at 2:55 am

Hi there,

The solution works just perfect! Thanks a million.
Almost there I hope… two other -related- questions…

1. I have placed 2 courses in my cart, one from the category ‘summerschool’ and another from the category ‘courses and seminars’. When looking in my cart through -let’s say- the widget ‘EE Mini cart widget’, there is another button ‘return to events list’ which sends me to the url from ‘event slug’ (EE4 > events > templates > event listing url). Is it possible that the button ‘return to events list’ returns me to the page with the events from the category that I last used or added?

2. Is there a way to add a specific sidebar to ‘single-espresso_events.php’ in my child theme, depending on the ‘espresso_event_categories’:
sidebar ‘summer school’ for espresso_event_category ‘summerschool’ and
sidebar ‘courses & seminars’ for espresso_event_category ‘summerschool’

Thanks in advanced for the excellent support!


Tony

  • Support Staff

May 19, 2020 at 8:50 am

1. I have placed 2 courses in my cart, one from the category ‘summerschool’ and another from the category ‘courses and seminars’. When looking in my cart through -let’s say- the widget ‘EE Mini cart widget’, there is another button ‘return to events list’ which sends me to the url from ‘event slug’ (EE4 > events > templates > event listing url). Is it possible that the button ‘return to events list’ returns me to the page with the events from the category that I last used or added?

Possible, yes, however we don’t have an examples of how to do it.

You’ll need to dig into the EE_Registry::instance()->SSN->checkout() object to pull the data you need.

2. Is there a way to add a specific sidebar to ‘single-espresso_events.php’ in my child theme, depending on the ‘espresso_event_categories’:
sidebar ‘summer school’ for espresso_event_category ‘summerschool’ and
sidebar ‘courses & seminars’ for espresso_event_category ‘summerschool’

Sure, if you are within single-espresso_events.php you’ll have Post object which means you can pull the current term and include any sidebar you want.

I can’t walk through all of the code to do this so is there a particular part you a stuck on?

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 1 week ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!