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

Viewing 16 reply threads


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 any 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?


efransen

June 3, 2020 at 2:43 am

This reply has been marked as private.


Tony

  • Support Staff

June 3, 2020 at 3:44 am

The site is behind basic auth so I can’t view anything.


efransen

June 3, 2020 at 6:14 am

This reply has been marked as private.


Tony

  • Support Staff

June 3, 2020 at 6:26 am

I haven’t gone through and looked at all of your events, but the first 5 I checked all have ‘Display Ticket Selector’ set to No.

It is expected that Event Espresso will not display the ticket selector when you set that option to no.


efransen

June 3, 2020 at 6:31 am

Hi Tony,
The events in the category ‘summerschool’ all have the ‘display ticket selector’ on yes, and they just don’t show up.


Tony

  • Support Staff

June 3, 2020 at 6:37 am

Is this using your own custom single-espresso_events.php template?

If so, are you calling for the ticket selector within the template and if so, can you post the template so I can take a look?


efransen

June 3, 2020 at 6:56 am

This reply has been marked as private.


Tony

  • Support Staff

June 3, 2020 at 7:31 am

Ok, so within your custom template your not calling any of the EE templates and just using it to change the layout of the page, correct?

Event Espresso injects the event details into the_content call but if you are using a custom template (single-espresso_events.php or archive-espresso_events.php) then it automatically assumes your are taking full control over the output and calling each specific section yourself.

In your template you are not doing that so you can add:

add_filter('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', '__return_true' );

to your theme’s functions.php file.

That will tell EE to continue to inject the additional event details even though you are using your own single template.


efransen

June 3, 2020 at 7:59 am

Hi Tony,
The piece of code you suggested to use in the functions.php of the child theme
add_filter('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', '__return_true' );was already included on line 13. So I don’t know what my next step should be to show the ticket selector on the single events.


Tony

  • Support Staff

June 3, 2020 at 8:10 am

Apologies, I missed that filter in your functions file.

Something else I missed is the fact that the ticket selector is indeed loading on your single event page, but your hiding it using CSS:

https://monosnap.com/file/x2iXd3NmriMEtCur1CyfAyXMIKDqMK

Line 890 of your child theme’s CSS has .tkt-slctr-tbl-wrap-dv {display:none;}

That is hiding the ticket selector on every page it would display.

You’ll need to remove that and whatever it was in use for will need to use a more specific selector.

Apologies for missing that earlier, templates on the brain I guess.


efransen

June 3, 2020 at 9:13 am

Now it’s my turn to apologize…
It just works perfect now.


efransen

June 3, 2020 at 10:44 am

Another question.
How can I change the url of the button ‘return to events list’?
I have this code already in a custom plugin, but it doesn’t work on the registration checkout page:

//Filter to change the URL for the "Back to List" button from the Multi Event Registration cart. Event Espresso 4 + Multi Event Registration
// Event espresso
// change default URL for "Return to Events List"

function tw_ee_mer_change_event_list_url_from_term($default_event_list){
	// Check if this is an ajax request.
	if (wp_doing_ajax()){
		// Check we have an event id.
		if (!empty($_POST['tkt-slctr-event-id'])) {
			$EVT_ID = absint($_POST['tkt-slctr-event-id']);
			if (has_term( 'courses-seminars', 'espresso_event_categories', $EVT_ID ) ){
				return 'https://url/courses-seminars/';
			} elseif (has_term( 'summerschool', 'espresso_event_categories', $EVT_ID ) ) {
				return 'https://url/summer-school/';
			}
		}
	}
	// Return the default event list url.
	return $default_event_list;
}
add_filter( 'FHEE__EED_Multi_Event_Registration__set_definitions__events_list_url', 'tw_ee_mer_change_event_list_url_from_term' );


efransen

June 3, 2020 at 11:47 am

Problem resolved. Thanks for all the help!

Viewing 16 reply threads

The support post ‘change default URL for "Return to Event list depending on event-category’ 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